locked
problem with recv AFTER SELECT!!! RRS feed

  • Question

  • it hangs on recv, the socket is returned from listen-> accept, any 1 ever seen something like this, or have any idea whats wrong?

     

    #define tcp_read(fd,data,len) (recv(fd,data,len,0))
    
    int read_tcp_socket(void* socket_handle, char* dst, int* len, int timeout){
    	
    	tcp_socket* sock = socket_handle;
    	fd_set fds;
    #ifdef _WIN32
    	struct timeval _timeout;
    #else
    	struct _timeval _timeout;
    #endif
    	_timeout.tv_sec = timeout;
    	_timeout.tv_usec = 0;
    	
    	FD_ZERO(&fds);
    	FD_SET((int)sock->handle,&fds);
    	
    	if(select((int)sock->handle+1,&fds,0,0,&_timeout) < 0){
    		return TCP_FAIL;
    	}
    	
    	*len = tcp_read(sock->handle,dst,*len);
    
    	return TCP_SUCCESS;
    }

     


    • Edited by hyva_hyypio Tuesday, November 29, 2011 7:52 AM
    Tuesday, November 29, 2011 7:49 AM