Results 1 to 9 of 9

Thread: Sending Multiple values through winsock??

  1. #1

    Thread Starter
    New Member
    Join Date
    Mar 2008
    Posts
    4

    Question Sending Multiple values through winsock??

    Through my searching into the tutorials and programs on the internet, i noticed that all examples concerning WINSOCK (in visual basic 6) talks about sending one value from client to server.

    I wonder if there is a way to send multiple values , coz i have the following task:

    I have 3 text boxes in the Client program , using winsock , i want to send these 3 values to another 3 text boxes in the Server program with just one click of "Send" button.

    if any body can help with the code i will be grateful

  2. #2
    Fanatic Member
    Join Date
    Oct 2004
    Posts
    751

    Re: Sending Multiple values through winsock??

    You can always use a delimiter and put them all in one string to send.
    Example:
    sPacket = Text1.Text + "|" + Text2.Text + "|" + Text3.Text
    (+ is the way to concantate strings right?)

    Then on the server tell it to split the string by "|" into an array which would fill 3 elements in the array, one for each text box.

    You use can use whatever you want for the delimiter.
    My Projects: [ Instant Messagener Client/Server ] [ VBPictochat ]

    My Sites:
    [ Datanethost ]
    [ Helpdesk ]

    Remember if my post was helpful then Rate This Post.

  3. #3

    Thread Starter
    New Member
    Join Date
    Mar 2008
    Posts
    4

    Re: Sending Multiple values through winsock??

    thanks a lot

  4. #4
    Member
    Join Date
    Feb 2008
    Posts
    57

    Re: Sending Multiple values through winsock??

    Ηallo guys, is there a way to sent the variable through network?
    To be more accurate, Ι have a an axis of my joystick, as myJoy.dwXpos, in my client's code.
    Is it possible to get it's value to my server?
    I want, to have it's value every, second, without pressing any cmdButton.
    For now, I have text1.text = myJoy.dwXpos, and with a cmdButton, I pass the value to my server.
    But this is not good.

  5. #5
    Fanatic Member
    Join Date
    Oct 2004
    Posts
    751

    Re: Sending Multiple values through winsock??

    You could use a timer.
    My Projects: [ Instant Messagener Client/Server ] [ VBPictochat ]

    My Sites:
    [ Datanethost ]
    [ Helpdesk ]

    Remember if my post was helpful then Rate This Post.

  6. #6
    Member
    Join Date
    Feb 2008
    Posts
    57

    Re: Sending Multiple values through winsock??

    Quote Originally Posted by k1ll3rdr4g0n
    You could use a timer.
    Thanks. It was very simple for someone to guess it.
    The problem is that I have no experience in programming, and many times I think that I have reached to a deadend

  7. #7
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,106

    Re: Sending Multiple values through winsock??

    What language are you using? It looks like .NET, in which case the line:

    text1.text = myJoy.dwXpos

    will only work with Option Strict Off. Turning Option Strict ON will improve performance by a significant amount, which you'd probably want to do for a game.

    As for when to send, and how to send, your two options would be a timer, and an event. The timer would send once a second, but that would be a bit slow for most situations, as people tend to do plenty with a joystick in a second. Also, it would keep going even when the user isn't doing anything with the joystick, which would be a waste. A better option might be to do the send when an event occurs. Exactly how that would work would depend on whether the joystick movement raises events itself, or whether you poll for joystick changes. If you are polling, you can send every N polls, where N is 1 or more, depending on how fast you want the messages to go. If the joystick triggers events, then just send the data when the event occurs. If this is too fast, then add a stopwatch, and send the data only when the stopwatch gets over some number of milliseconds. You'd just need to remember to reset the stopwatch every time you sent something.
    My usual boring signature: Nothing

  8. #8
    "Digital Revolution"
    Join Date
    Mar 2005
    Posts
    4,471

    Re: Sending Multiple values through winsock??

    A timer can fire every millisecond. You could also just store the values of the last x/y coordinates and only send again when they have changed.

    An event would be much better though...not sure if there are any. There might be if you used DirectX or something but I wouldn't use it just for that.

    Edit: Actually, if you're making a game then you may want to use DirectX...
    Last edited by DigiRev; Apr 1st, 2008 at 04:27 PM.

  9. #9
    Member
    Join Date
    Feb 2008
    Posts
    57

    Re: Sending Multiple values through winsock??

    Ηallo guys, I am very new in programming and I use VB 6.
    I want to make a project to fly a helicopter through laptop and wireless.
    So when you mention event, what exactly is that? Where can I find it? And how can I use it?
    I just used a timer (10ms), and for now I am satisfied.
    The thing I can't find, is when the Xpos, pass through socket, and put it on a variable, how can I check when the x/y pos is changed?
    How can I print to the textbox only the last value of the variable?
    Last edited by manin; Apr 2nd, 2008 at 04:25 PM.

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