async socket issues

This is a discussion on async socket issues within the Windows Programming forums, part of the Platform Specific Boards category; well im having some difficulties sending to the server i send but it never reaches the server? anyways im including ...

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    254

    async socket issues

    well im having some difficulties sending to the server i send but it never reaches the server?

    anyways im including everything i think is relevant :P
    Code:
    case WM_WSAASYNC:
    		{
    			switch(WSAGETSELECTEVENT(lParam))
    			{
    			case FD_READ:
    				{
    					buffer=ReadData(hwndServerBox);
    					if(buffer.length()>0)
    						Analyze(hwndServerBox,buffer);
    				}break;
    
    //-----------------------------------------------------------------------------------
    bool WriteData(HWND hwndServerBox,string buffer)//the issue is in here as my data is never actually sent?
    {	
    	int nret;
    	int BytesToSend=sizeof(buffer);
    
    	if (BytesToSend<=0)
    		return false;
    
    	nret=send(sock,buffer.c_str(),BytesToSend,0);
    
    	if(nret==SOCKET_ERROR)
    	{
    		PostText(hwndServerBox,"Error: Send()");
    		return false;
    	}
    	else
    		PostText(hwndServerBox,buffer);
    	return true;
    }
    i was told to disregard WM_WRITE as it is only useful when sending large amounts of data because you have to fill up the network buffer...
    Last edited by ZerOrDie; 03-16-2003 at 02:44 PM.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>int BytesToSend=sizeof(buffer);
    This isn't the way to determine the string length. Try buffer.length() and don't forget to account for the null terminating byte if you want to send that too.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    254
    Originally posted by Hammer
    >>int BytesToSend=sizeof(buffer);
    This isn't the way to determine the string length. Try buffer.length() and don't forget to account for the null terminating byte if you want to send that too.
    yeah i was using .length() before and switched it over after reading some async socket site... still does not resolve my problem though

    heh i could up my full source its around 300 lines though

    EDIT:
    i feel like a dunce again lol i wasnt sending a "\n" along with my string :P i feel so stupid lol
    Last edited by ZerOrDie; 03-16-2003 at 05:57 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. socket programming question, closing sockets...
    By ursula in forum Networking/Device Communication
    Replies: 2
    Last Post: 05-31-2009, 05:17 PM
  2. Winsock issues
    By tjpanda in forum Windows Programming
    Replies: 3
    Last Post: 12-04-2008, 07:32 AM
  3. async Client/Server app, accept() stalls?
    By JaWiB in forum Networking/Device Communication
    Replies: 14
    Last Post: 01-31-2005, 04:59 PM
  4. Error on Async socket startup!
    By SyntaxBubble in forum Windows Programming
    Replies: 4
    Last Post: 03-16-2002, 06:36 PM
  5. Async Socket Examples?
    By SyntaxBubble in forum Windows Programming
    Replies: 1
    Last Post: 01-04-2002, 05:08 PM

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