Thread: recv large amounts of data

  1. #16
    Registered User
    Join Date
    Aug 2008
    Posts
    67
    Quote Originally Posted by master5001 View Post
    Yep.
    Oh. Battle.net's CHAT protocol hasn't changed in over a decade.

  2. #17
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Then the +11 thing should be fine I just thought I would give you "the talk" about skipping constants like that since if I don't someone else surely will.

    Its good to know you are fundamentally having something like this occur.

    Code:
    RESP: 123456 xkpreston
    RESP: 092342 ymaster5001
    And simply noticing "Gee, I don't really need that 'RESP: ' crap, do I? Plus it seems to always be the same. So I guess I can skip the first 6 characters."

    Same idea with the +11 thing.

  3. #18
    Registered User
    Join Date
    Aug 2008
    Posts
    67
    Bonus question #2!

    I need connect to timeout. I'm trying to convert what I already have to use non-blocking sockets and select(), but I'm failing. It claims to be connected, but it never actually logs on or receives data. Am I using select() correctly?

    Code:
    	FD_ZERO(&sockets);
    	FD_SET(s, &sockets);
    	timeout.tv_sec = 0;
    	timeout.tv_usec = 100;
    
    	printf("Connecting...\n");
    	connect(s, (struct sockaddr*)&sin, sizeof(sin));
    	while (select(0, NULL, &sockets, NULL, &timeout) == SOCKET_ERROR) {
    		printf("[%d] ", WSAGetLastError());
    		printf("Retrying connection...\n");
    		connect(s, (struct sockaddr*)&sin, sizeof(sin));
    
    		FD_ZERO(&sockets);
    		FD_SET(s, &sockets);
    	}
    Edit1:

    Code:
    	FD_ZERO(&sockets);
    	FD_SET(s, &sockets);
    	timeout.tv_sec = 0;
    	timeout.tv_usec = 900;
    
    	printf("Connecting...\n");
    	connect(s, (struct sockaddr*)&sin, sizeof(sin));
    	
    	ret = select(s+1, NULL, &sockets, NULL, &timeout);
    	while (ret == 0 || ret == SOCKET_ERROR) {
    		printf("[%d] ", WSAGetLastError());
    		printf("Retrying connection...\n");
    		connect(s, (struct sockaddr*)&sin, sizeof(sin));
    
    		FD_ZERO(&sockets);
    		FD_SET(s, &sockets);
    		ret = select(s+1, NULL, &sockets, NULL, &timeout);
    	}
    And it works. However, if I set tv_usec to 999 and under, I get [10035] Retrying connection, [10037] Retrying connection, [10037] Retrying connection, [10037] Retrying connection, Connected!. Why is this? Do I have to close the socket and create a new, every time I retry the connection?

    Edit2: Durrrr. Microseconds.

    Do I have to close the socket and create a new, every time I retry the connection?
    Last edited by kpreston; 10-16-2008 at 02:49 PM.

  4. #19
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    MSVS comes with a program to tell you what these errors mean... But here you go

    Quote Originally Posted by 10035
    Resource temporarily unavailable. This error is returned from operations on non-blocking sockets that cannot be completed immediately, for example recv() when no data is queued to be read from the socket. It is a nonfatal error, and the operation should be retried later. It is normal for WSAEWOULDBLOCK to be reported as the result from calling connect() on a non-blocking SOCK_STREAM socket, since some time must elapse for the connection to be established.
    Quote Originally Posted by 10037
    Operation already in progress. An operation was attempted on a non-blocking socket with an operation already in progress - that is, calling connect() a second time on a non-blocking socket that is already connecting, or canceling an asynchronous request (WSAAsyncGetXbyY) that has already been canceled or completed.
    Sockets on windows can be such a piece of crap at times. This is so much easier to do on linux.

  5. #20
    Registered User
    Join Date
    Aug 2008
    Posts
    67
    So... I DO have to close the socket and create a new one if I want to stop a connection in progress and reconnect?

    P.S. Thank you for being so patient with me.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. xor linked list
    By adramalech in forum C Programming
    Replies: 23
    Last Post: 10-14-2008, 10:13 AM
  2. Large Data management in using File
    By mohsan1987 in forum C Programming
    Replies: 6
    Last Post: 09-14-2006, 06:41 AM
  3. Reading large complicated data files
    By dodzy in forum C Programming
    Replies: 16
    Last Post: 05-17-2006, 04:57 PM
  4. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM
  5. accepting large amounts of data
    By Sekti in forum C++ Programming
    Replies: 1
    Last Post: 04-05-2002, 05:45 PM