Results 1 to 11 of 11

Thread: Winsock

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    181

    Winsock

    If I have got an IP address that I want to see is my "server", how can I send a certain bit of data (My IP, then a confirmation message) to the server, and then get the server to recieve it (I need this code as well), before finally (if the server does send a verification message), save that IP to a string?

  2. #2
    Lively Member
    Join Date
    Mar 2001
    Location
    Sweden
    Posts
    115
    Check out this Winsock article and maybe you'll get some help there.

  3. #3
    Addicted Member csammis's Avatar
    Join Date
    Mar 2001
    Location
    /dev/null
    Posts
    226
    That is a very good article, but if you have any other questions do feel free to post, I (and many others here!) have good experience coding both server and client apps
    Things I've Said:
    "Life's funny like that...elephants can wear frilly lace panties, and Dubya still looks like a monkey in a big chair"
    "Take four goats and strap one to each foot of a llama. Presto, goat-powered llama!"
    "You want to get me to work more, get me a Coke. No? Then deal with inferior garbage, I'm not coding another line and your clients can go to......thanks, I'd love a Coke right about now!"

  4. #4
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177
    If you search the MSDN site, you will find the following description of the error. http://support.microsoft.com/support.../Q183/9/87.ASP

    If you followed the example, the problem is most likely due to the socket being closed before the SendData finished its task.

    If you want to close the connection after the data has been sent, put the Winsock1.Close in a Winsock1_SendComplete routine.

  5. #5
    Addicted Member csammis's Avatar
    Join Date
    Mar 2001
    Location
    /dev/null
    Posts
    226
    Good call, ccoder...I spent a while playing with the example, not seeing adamcox's error...turns out it's a VB5 thing...oh, that crazy Microsoft
    Things I've Said:
    "Life's funny like that...elephants can wear frilly lace panties, and Dubya still looks like a monkey in a big chair"
    "Take four goats and strap one to each foot of a llama. Presto, goat-powered llama!"
    "You want to get me to work more, get me a Coke. No? Then deal with inferior garbage, I'm not coding another line and your clients can go to......thanks, I'd love a Coke right about now!"

  6. #6
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177
    Originally posted by csammis
    ...turns out it's a VB5 thing...oh, that crazy Microsoft
    Do you know for a fact that it is a VB5 thing? I know the MSDN says it applies to V5.0. I've never had the problem 'cause I always keep my connection up until I am ready to terminate the app. Too much overhead to constantly connect, send, recieve and disconnect.

  7. #7
    Addicted Member csammis's Avatar
    Join Date
    Mar 2001
    Location
    /dev/null
    Posts
    226
    Well, I tried the example on VBWorld and it worked for me...maybe I'm just lucky!
    Things I've Said:
    "Life's funny like that...elephants can wear frilly lace panties, and Dubya still looks like a monkey in a big chair"
    "Take four goats and strap one to each foot of a llama. Presto, goat-powered llama!"
    "You want to get me to work more, get me a Coke. No? Then deal with inferior garbage, I'm not coding another line and your clients can go to......thanks, I'd love a Coke right about now!"

  8. #8
    Junior Member
    Join Date
    Apr 2001
    Posts
    22
    No luck, the tutorial doen't work for me. And i tried it with
    VB 6.0. I got the tutorial to work to a certain extend (i can send the message once, when i try to send it a second time, it crashes). I took the link to the messenger program by Evan Christopher Sims, and that does work for, although not stable.

    One question concerning this program: what is the best (read quickest) way to use winsock? The program checks every twenty second for changes in status, and it takes a long time to do that. How does icq do that?

    NeoMotion
    ----------------------------
    VB 6.0
    Almost MCP ;-)
    All round nice guy

  9. #9
    Addicted Member csammis's Avatar
    Join Date
    Mar 2001
    Location
    /dev/null
    Posts
    226
    If ICQ was written in VB using the Winsock control (dunno that it is), it'd wait for Winsock's many and varied events to fire. Error control, waiting for sends to complete, being alerted when data arrives...it's all good with event-driven programming
    Things I've Said:
    "Life's funny like that...elephants can wear frilly lace panties, and Dubya still looks like a monkey in a big chair"
    "Take four goats and strap one to each foot of a llama. Presto, goat-powered llama!"
    "You want to get me to work more, get me a Coke. No? Then deal with inferior garbage, I'm not coding another line and your clients can go to......thanks, I'd love a Coke right about now!"

  10. #10
    Frenzied Member
    Join Date
    Aug 2000
    Location
    O!
    Posts
    1,177
    Originally posted by Neomotion
    No luck, the tutorial doen't work for me. And i tried it with
    VB 6.0. I got the tutorial to work to a certain extend (i can send the message once, when i try to send it a second time, it crashes).
    Two questions regarding the client side!
    1) are you specifying a LocalPort?
    2) are you closing the socket after each send and reopening it?

    If yes to both, don't specify a LocalPort. Let the OS assign one for you. The problem has to do with the TIME_WAIT value which allows TCP to ensure that connections are properly closed. The side initiating the close must hang around long enough for the other side to send its final packet.

    If you try to reconnect too soon after closing, you will have this problem. By not specifying a port number, the OS will find a port that isn't tied up and assign it.

    Another question regarding the server side!
    Do you check the socket state for sckClosing (value = 8 indicating that the peer is closing the connection)? When the socket goes to this state, you should close and go back to listening. BTW, this only applies to a server with a single socket control.

  11. #11
    Addicted Member csammis's Avatar
    Join Date
    Mar 2001
    Location
    /dev/null
    Posts
    226
    ccoder, a bit off-topic...but I'd like you to take a look at this thread - http://www.vbforums.com/showthread.p...threadid=84411

    It's a ponderance on why the socket layer is the way it is, I'd like your thoughts on the matter since you know your socket stuff
    Things I've Said:
    "Life's funny like that...elephants can wear frilly lace panties, and Dubya still looks like a monkey in a big chair"
    "Take four goats and strap one to each foot of a llama. Presto, goat-powered llama!"
    "You want to get me to work more, get me a Coke. No? Then deal with inferior garbage, I'm not coding another line and your clients can go to......thanks, I'd love a Coke right about now!"

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