Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
1.50/5 (4 votes)
See more:
I learned about the socket.I using winform of C# 2005.
Most server,client must write two separate programs.
Can write a chat program network LAN has both the function server client functionality?
Posted
Updated 14-Nov-11 3:47am
v3

Here is the CP article

Introduction to TCP client server in C#[^]
 
Share this answer
 
Comments
giatuan2011 14-Nov-11 23:21pm    
Thank you.
Your solution is what I have learned.
I need a program for the server and client with form
Yes it has both the functions.
 
Share this answer
 
Comments
giatuan2011 14-Nov-11 23:24pm    
Only one program is used for server and client are what you say?
I learned the two are separate
giatuan2011 14-Nov-11 23:25pm    
Have You only one for both?
Yes.
 
Share this answer
 
Any application can both listen to a TCP port (server) on connect to a remote TCP port (client). The only restriction is that (generally) only one application can bind to a port for listening.
 
Share this answer
 
Hi there,

Yes it is possible, but its performance would be at a low level.
to make a correct architecture and high performance networking software you should use a multi-threaded programming technics.


Best Regards.
 
Share this answer
 
Comments
#realJSOP 14-Nov-11 8:52am    
Why would you think performance would suffer? It's a chat application, and nothing more. If it were me, I'd make the program act as EITHER a server or a client. The first instance that fires up would be a server, and all other instances would be clients. Where is the performance degradation?
elgaabeb 14-Nov-11 9:06am    
giatuan2011 said :
"Can write a chat program network LAN has both the function server client functionality? "
==> He want to make a unique instance to act as client and sever.
he also said :
"Most server,client must write two separate programs"
He is not talking about two seperate programs client and server, that's classic and he knows this case.
you were talking about two instance, it will act as multi-threaded program and no performance ill would be observed!!
Please let the user who asked the question to judge on the response according to his aims!!
Thank you.
#realJSOP 14-Nov-11 10:11am    
I know - I said make a program that can act as EITHER a client OR a server. The first instance that runs is the server and acts ONLY as a server. The 2nd instance that runs acts as a client, and ONLY a client. By definition, each instance is running on its own thread (or thread pool). That was the entire point of what I said.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900