Thread: Winsock logic

  1. #1
    Registered User
    Join Date
    May 2002

    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:

    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
                                   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
    One possible issue is the server-side, not client-side. Make sure the server correctly binds the listening socket.


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, 08:32 AM
  2. Digital Logic
    By strokebow in forum Tech Board
    Replies: 3
    Last Post: 12-09-2006, 01: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, 12:11 PM