winsock problem...

This is a discussion on winsock problem... within the Windows Programming forums, part of the Platform Specific Boards category; i would like to wite my own telnet client... but my problem is how to make the program to recv() ...

  1. #1
    * Death to Visual Basic * Devil Panther's Avatar
    Join Date
    Aug 2001
    Posts
    768

    winsock problem...

    i would like to wite my own telnet client... but my problem is how to make the program to recv() the data... all the time.
    what i mean is how do i now when there is incoming data, so then i could use recv(), because i know that recv() returns zero on connection ternomated, and blocks the connection when there is no incoming data...

    what do i do???

    thanks guys...
    "I don't suffer from insanity but enjoy every minute of it" - Edgar Allen Poe

    http://www.Bloodware.net - Developing free software for the community.

  2. #2
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    One solution is a non-blocking I/O model.

    I highly recommend Network Programming for Microsoft Windows, Second Edition by Anthony Jones and Jim Ohmund.

    Kuphryn

  3. #3
    Xei
    Xei is offline
    Registered User Xei's Avatar
    Join Date
    May 2002
    Posts
    719

    What I did...

    What I did was create a DLL to handle any internet connections I wanted, and I incorporated its own callback functions. So what it does is create a thread per socket, then that thread monitors the socket using WSAWaitForMultipleEvents, and WSAEnumNetworkEvents to find out which activity has occured. Afterwards it just sends that data to a function defined by the Win32 application, then it can use another function in the DLL to read the data when it decides to.

  4. #4
    Registered User
    Join Date
    Nov 2001
    Posts
    1,348
    In this case, the DLL needs a mean to communicate with the parent process and update the process upon incoming data.

    One solution is to update the DLL with a safe handle of the parent process. As an event triggers WaifForMultipleObjects() or events, the DLL sends a message to the parent process.

    Kuphryn

  5. #5
    i want wookie cookies the Wookie's Avatar
    Join Date
    Oct 2002
    Posts
    455
    I think you use "Asyncronous Sockets", I'm not sure of the exact name, but I have some of my winsock code...

    Code:
    //in your callback function
    
    LRESULT CALLBACK MainWndProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam) {
    	switch(wMsg)	{
    		case CONNECTION_PENDING:
    			if(LOWORD(lParam)==8){
    				//accept
    			}
    			break;
    		case DATA_PENDING:
    			if(LOWORD(lParam) == FD_CLOSE) {	
    				//disconnecting from client
    			}
    			//receive data here
    		break;
    	}
    }
    thats the basic code i use..works well for what i need/use it for

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. 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
  2. Winsock packet problem
    By Rare177 in forum Windows Programming
    Replies: 7
    Last Post: 10-05-2004, 04:53 PM
  3. Winsock Problem
    By Noxir in forum C++ Programming
    Replies: 4
    Last Post: 07-18-2004, 10:50 AM
  4. WinSock Problem
    By loobian in forum C++ Programming
    Replies: 1
    Last Post: 02-09-2002, 10:25 AM
  5. Small Winsock problem...
    By SyntaxBubble in forum C++ Programming
    Replies: 0
    Last Post: 02-09-2002, 09:09 AM

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