Click to See Complete Forum and Search --> : UDP socket
nasrul
December 23rd, 2004, 09:36 PM
hi guys,
I have a question. I have a client/server application. Can I set the bind() to both of my client and server. I want to do this because I want to be able to make connection either from client or server. How do I do that? Should I put bind() in client too?
drewdaman
December 27th, 2004, 03:18 PM
Can I set the bind() to both of my client and server.
What do you mean by that?
I want to do this because I want to be able to make connection either from client or server. How do I do that? Should I put bind() in client too?
Make a sockaddr_in in your client and server... and bind your socket in each to the sockaddr_in. you should always bind a socket to a sockaddr to make it usable. why do you wnat to the server to initiate a connection to the client?
i'm not really sure if that is what you're asking... but... here's hoping it helps!
dinus
December 27th, 2004, 03:48 PM
Lets say you have 2 machines (M1 and M2). You can create listener sockets on both of them, for example:
----------------------------
ListenSock=socket(AF_INET, SOCK_STREAM, NULL);
bind(ListenSock,(struct sockaddr*)&server,sizeof(server));
DataSock = accept(ListenSock,(struct sockaddr *)&client,&iAddrSize);
---------------------------
In this example you will have to use a separate thread for listeners, since "accept" function will block untill a request from client is received.
Later, you can decide to connect from M1 to M2, or from M2 to M1, or even both at the same time. Server machine will always listen on the port specified in sin_port (see sockaddr_in structure), and Client machine will always open a port (>1024) to connect to server Machine.
Is that what you wanted to do?
Regards.
nasrul
December 27th, 2004, 09:04 PM
For your information, I am developing a video conferencing application. In Video conferencing application, both parties can initiate a connection. So, do you have any example in UDP on how I can do that since in the web, the example is a client/server architecture where the client has to make a connection to the server. Hope you can guide me on this matter.
Ejaz
December 28th, 2004, 03:58 AM
For your information, I am developing a video conferencing application. In Video conferencing application, both parties can initiate a connection. So, do you have any example in UDP on how I can do that since in the web, the example is a client/server architecture where the client has to make a connection to the server. Hope you can guide me on this matter.
Have a look at VideoNet: Peer to Peer Video Conference Application (http://www.codeguru.com/Cpp/G-M/multimedia/video/article.php/c7621/)
For further information about P2P: Distributed Video on Demand Services on Peer to Peer Basis (http://www.c-lab.de/data/Publication_DB/DB/Loeser_Christoph_00/RTILA02.pdf)
nasrul
December 28th, 2004, 04:07 AM
I already seen the VideoNet example. It using CSocket class. I want to do it using Winsock API because I think API is more efficient compared to MFC. So how do I do that using Winsock API?
Ejaz
December 28th, 2004, 04:16 AM
Beginning Winsock Programming - Simple TCP server (http://www.codeproject.com/internet/WinSockIntro01.asp)
Beginning Winsock Programming - Simple TCP client (http://www.codeproject.com/internet/winsockintro02.asp)
nasrul
December 28th, 2004, 01:16 PM
where can i find UDP sample?
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.