Click here to Skip to main content
15,867,686 members
Home / Discussions / C#
   

C#

 
Questionhow to send and recieve data from different ip using socket server Pin
Ajithevn19-Oct-09 21:32
Ajithevn19-Oct-09 21:32 
AnswerRe: how to send and recieve data from different ip using socket server Pin
Richard MacCutchan19-Oct-09 22:58
mveRichard MacCutchan19-Oct-09 22:58 
GeneralRe: how to send and recieve data from different ip using socket server Pin
Ajithevn19-Oct-09 23:15
Ajithevn19-Oct-09 23:15 
GeneralRe: how to send and recieve data from different ip using socket server Pin
Richard MacCutchan20-Oct-09 0:03
mveRichard MacCutchan20-Oct-09 0:03 
QuestionRe: how to send and recieve data from different ip using socket server [modified] Pin
Ajithevn20-Oct-09 0:27
Ajithevn20-Oct-09 0:27 
AnswerRe: how to send and recieve data from different ip using socket server Pin
Richard MacCutchan20-Oct-09 1:24
mveRichard MacCutchan20-Oct-09 1:24 
GeneralRe: how to send and recieve data from different ip using socket server Pin
Ajithevn20-Oct-09 2:39
Ajithevn20-Oct-09 2:39 
AnswerRe: how to send and recieve data from different ip using socket server Pin
Jimmanuel20-Oct-09 3:12
Jimmanuel20-Oct-09 3:12 
Just because you called tcpListener.AcceptSocket() once doesn't mean that you can't call it again. You can have as many sockets connected to your server at the same time as you want.

All you need is some better plumbing in your server to do multiple things at once: listen for clients that are trying to connect, listen to clients that have already connected for data and send received data to other connected clients. You can do this with some proper multi-threading and synchronous methods like you're doing now, but if you have the time and the drive to learn something new then using asynchronous methods would probably provide a cleaner, more elegant solution.

MSDN has a decent example of how to listen for new clients asynchronously here: TcpListener.BeginAcceptSocket[^] and TcpListnener.BeginAcceptTcpClient[^]

To continue with the async theme, the TcpClient class also has async methods to handle sending and receiving data. Examples of those are on MSDN as well.

Of course, this may be overkill depending on what you need . . .


Badger | [badger,badger,badger,badger...]

QuestionMulti-threaded SOAP calls to different servers a problem? Pin
gstar4219-Oct-09 21:18
gstar4219-Oct-09 21:18 
AnswerRe: Multi-threaded SOAP calls to different servers a problem? Pin
Mirko198019-Oct-09 22:37
Mirko198019-Oct-09 22:37 
GeneralRe: Multi-threaded SOAP calls to different servers a problem? Pin
gstar4220-Oct-09 4:08
gstar4220-Oct-09 4:08 
GeneralRe: Multi-threaded SOAP calls to different servers a problem? Pin
Mirko198020-Oct-09 4:30
Mirko198020-Oct-09 4:30 
GeneralRe: Multi-threaded SOAP calls to different servers a problem? Pin
gstar4220-Oct-09 4:33
gstar4220-Oct-09 4:33 
GeneralRe: Multi-threaded SOAP calls to different servers a problem? Pin
Mirko198020-Oct-09 5:58
Mirko198020-Oct-09 5:58 
QuestionVideo display Pin
saran.m19-Oct-09 21:15
saran.m19-Oct-09 21:15 
AnswerRe: Video display Pin
Christian Graus20-Oct-09 0:04
protectorChristian Graus20-Oct-09 0:04 
QuestionHow to insert data into a GridView from the textboxes Pin
Nopo19-Oct-09 20:55
Nopo19-Oct-09 20:55 
AnswerRe: How to insert data into a GridView from the textboxes Pin
Calla19-Oct-09 21:12
Calla19-Oct-09 21:12 
GeneralRe: How to insert data into a GridView from the textboxes Pin
Nopo19-Oct-09 21:23
Nopo19-Oct-09 21:23 
AnswerRe: How to insert data into a GridView from the textboxes Pin
nagendrathecoder19-Oct-09 21:26
nagendrathecoder19-Oct-09 21:26 
GeneralRe: How to insert data into a GridView from the textboxes Pin
Nopo19-Oct-09 21:30
Nopo19-Oct-09 21:30 
GeneralRe: How to insert data into a GridView from the textboxes Pin
nagendrathecoder19-Oct-09 21:38
nagendrathecoder19-Oct-09 21:38 
GeneralRe: How to insert data into a GridView from the textboxes Pin
Nopo19-Oct-09 21:42
Nopo19-Oct-09 21:42 
GeneralRe: How to insert data into a GridView from the textboxes Pin
nagendrathecoder19-Oct-09 21:45
nagendrathecoder19-Oct-09 21:45 
AnswerRe: How to insert data into a GridView from the textboxes Pin
stancrm19-Oct-09 21:41
stancrm19-Oct-09 21:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.