Results 1 to 2 of 2

Thread: TCP Commands

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2006
    Posts
    114

    TCP Commands

    Well, i've got my client and server running, but im not sure how to send commands. I know to use the SendData or whatever but how would i send a command so that the other one executes a function upon recieving it?

  2. #2
    PowerPoster
    Join Date
    Dec 2003
    Posts
    4,787

    Re: TCP Commands

    Ok,

    Step back and look at whats going on. To make a function execute on the client side (for example) there is no set method more your going to have to work out some programming logic and set somthing up yourself. A commonly used method involves creating 'symbols' for functions eg

    We are going to send a command which issues a function of the client that pops a messagebox with the text we send. So!

    From the server you will need to send the command and the text!

    VB Code:
    1. dim iText as string
    2.  
    3. iText = inputbox("Enter the text!")
    4.  
    5. Winsock.SendData("589," & iText)

    2 things to notice, the 589 which will be our command for inititaing the function the dilimeter (,) and then our text.

    When the client recieves this data it needs to interpret it.....

    VB Code:
    1. 'Data arrival
    2.  
    3. dim idata as string
    4. dim icommand as string
    5. dim temp() as string
    6.  
    7. Winsock.GetData(iData)
    8.  
    9. temp = split(idata,",")
    10.  
    11. icommand =temp(0)
    12.  
    13. If icommand = "589" then
    14.      call ourFunction(temp(1))
    15. End if
    16.  
    17. 'then our function
    18.  
    19. Private sub ourFunction(TheText as string)
    20.      msgbox(thetext)
    21. end sub

    Just think of some effective ways of doing it uses small commands as not to waste memory etc

    Pino

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width