identifying a client

Can i recognize a client without receiving data on server from this client. I have two clients, where client one would send a message to client 2. Client 2 must receive this message to begin the processing and send back other necessary datas to client 1.

My two clients are communicating with eachother only when datas are received atlist once at the server.

can i make it anyway that client2 will be identified without sending a message to server only by connection ?

Let me know if you have an idea or sample code on this..
Yes.

The server accepts client connections with accept(). accept() returns a socket to talk to the client on, but it also returns the client's address.
will it be possible to use accept in UDP socket?

As far as i know, UDP can be implemented with following ways

socket()
bind()
recvfrom()
sendto()

Kindly suggest me any possible link to know how can i do it. ??
Last edited on
No, but you'd use recvfrom() for UDP gives you the same information.

Can i recognize a client without receiving data on server from this client.
There is no connection or session with UDP, you just get stuff from a client with recvfrom().
Would you suggest how can i solve this issue.

client1 sends data to server and server must send this data to client2, then only client 2 will be able to communicate further. Client2 will be activated only when it receives the correct datagram from client1.

client1 ---- > Server ------> client2 (must receive the first telegram )

after first telegram is received at client 2 , both client 1 and client2 operate like a simple chat server.
That implies that client2 is a server, right?

So Server must have client2's address to contact it.

That's ok, so long as that is what your intend. There's no point in writing code until you've confirmed what you want to do.
Last edited on
Yes. Exactly Client 2 is also Server. How can i give client 2 address ?

It is only being recognized after a packet is received from client 2 at Server. But in reality Client 2 will only Start when a datagram from client 1 is received by it.

How can i give client 2 address ?

Finding services is always problematic. But the answer is configuration; place the configuration in a file and have the program read it at startup.

My guess is that you really only have one program that's configured differently for different contexts.
Instead of using a configuration file, broadcasting would be another way of finding services. The initiator, say client1, sends a broadcast telegram to a port commonly known by all servers, asking for service request. The server, say client2, implicitly gets client1 address when using recvfrom(). So client2 may answer a client1 request.
@tcs Is it available in UDP ??
Yes, write to the broadcast address to broadcast on your local network, only available in UDP.
https://en.wikipedia.org/wiki/Broadcast_address#IP_networking

You need multicast (IGMP) to broadcast beyond your local network.
https://en.wikipedia.org/wiki/Internet_Group_Management_Protocol
Last edited on
@kbw:

I solved this issue somehow and i know how it can be identified. I have come accross anothe r issue after your suggestions on receiving strings here on this post.

plz have a look

http://www.cplusplus.com/forum/unices/148461/
Topic archived. No new replies allowed.