Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   C++ (http://www.programmingforums.org/forum15.html)
-   -   sockets (http://www.programmingforums.org/showthread.php?t=10125)

hbe02 Jun 1st, 2006 8:13 PM

sockets
 
These are my initializations, assume all is correct with connecting to windows etc... i want to recieve data form the client on the socket "incoming" and i want to send information to the client on socket "outgoing"
these are some form of my initializations, assume all is correct
:

int incoming = socket(AF_INET, SOCK_DGRAM, 0);
int outgoing = socket(AF_INET, SOCK_DGRAM, 0);
sockaddr_in & server;
sockaddr_in & client;

assignserver(server) ; //this function assigns IP and port to my station (server)
assignserver(client) ; //this function assigns IP and port to my station (server)

bindfunction(incoming,server) // this binds server(me) to socket incoming



here is the psuedocode of what i want to do ... how can i do it?

:

while(true)
{
        if(recieve anything on socket incoming)
                {

                        process information;
                }
        else // nothing is recived
                {
                        output some data to client on the outgoing socket;
                }
}


so what i want to do is keep sending data on the outgoing socket forever and ever. when i recieve data on the incoming socket, i want to stop sending on the outgoing socket and process the information i recieve on the incoming socket..
i have tried WSANETWORKEVENTS.. which didnt work out very well since i couldnt find proper sources.. can someone please give me proper code or link.. where i can see what i want to do in action so i can understand and do the same...
thanks

Harakim Jun 1st, 2006 9:22 PM

I'd imagine you want to use poll(), which means you will need to use non-blocking sockets. I would post links but I'm on a group dial-up right now and it takes about a minute to access a page. Search for: non-blocking i/o c++


All times are GMT -5. The time now is 8:00 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC