Thread: sockets
View Single Post
Old Jun 1st, 2006, 8:13 PM   #1
hbe02
Hobbyist Programmer
 
hbe02's Avatar
 
Join Date: Mar 2006
Location: Lebanon
Posts: 148
Rep Power: 3 hbe02 is on a distinguished road
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
hbe02 is offline   Reply With Quote