Winsock logic

This is a discussion on Winsock logic within the Networking/Device Communication forums, part of the General Programming Boards category; Here is what I want the CLIENT to do. Check and see if the server is up, if not, keep ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    100

    Winsock logic

    Here is what I want the CLIENT to do.

    Check and see if the server is up, if not, keep trying until it is.
    If the server is up, then connect to it.
    If the server goes offline or quits. Go back to step 1.

    Here is my code so far:

    Code:
    while(1) {
    		nret = connect(serverSocket, (LPSOCKADDR)&serverInfo, 16);
    
    		if(nret == SOCKET_ERROR) {
    			connected = false;
    		}
    		else {
    			recvResponse(serverSocket, true); // recieves server's welcome message
    			connected = true;
    		}
    
    		while(connected) {
                             // do stuff
                             if(server_disconnects)
                                   connected = false;
    		}
    	}
    This works fine for one connection, but If the server quits, and then restarts, the client will NOT connect.


    Any suggestions?

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    One possible issue is the server-side, not client-side. Make sure the server correctly binds the listening socket.

    Kuphryn

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Winsock issues
    By tjpanda in forum Windows Programming
    Replies: 3
    Last Post: 12-04-2008, 07:32 AM
  2. Digital Logic
    By strokebow in forum Tech Board
    Replies: 3
    Last Post: 12-09-2006, 12:05 PM
  3. Winsock Messaging Program
    By Morgul in forum Windows Programming
    Replies: 13
    Last Post: 04-25-2005, 04:00 PM
  4. Where do I initialize Winsock and catch messages for it?
    By Lithorien in forum Windows Programming
    Replies: 10
    Last Post: 12-30-2004, 11:11 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21