Idanis
Idanis

Reputation: 1988

Sending messages from server to client c#

My client sends messages to the my server using tcp protocol (my server has a listener). I'm trying to send messages back from the server to the client, but I'm not sure what do I need to add to the client in order to get those messages. I tried looking it up, but I didn't understand how to implement it.

Could you please assist?

Upvotes: 0

Views: 4684

Answers (3)

MarcF
MarcF

Reputation: 3299

If you want a console example of a client server application using a network library see here http://www.networkcomms.net/how-to-create-a-client-server-application-in-minutes/.

If you want a WPF application example then see here http://www.networkcomms.net/creating-a-wpf-chat-client-server-application/

Upvotes: 0

Thorsten Dittmar
Thorsten Dittmar

Reputation: 56727

If you intend to receive messages independently (i.e. not in response to a request by the client), you need to make the client a TCP server, too. The client needs to implement exactly the same thing as the server you have now and the server needs to connect to the client.

Can't you use WCF, which supports callback contracts?

Upvotes: 0

Captain Kenpachi
Captain Kenpachi

Reputation: 7215

It's the exact same process, but in reverse.

Upvotes: 2

Related Questions