Question Sending data from client windows application to server console application

sweety

New member
Joined
Aug 28, 2012
Messages
1
Programming Experience
Beginner
What i'm trying is sending data from client which is windows application to server which is console application.
First i have to start console application and accept connection from client which is windows form and i need to send listbox selected items to console application on button click.This i have to do through socket programing.
I'm new to socket programing.
can any1 help me on this.
 
System.Net.Sockets Namespace () has the tools you need for socket programming. For example you can use TcpClient/TcpListener for TCP protocol, or UdpClient for UDP protocol. You can find much help in documentation and also by searching web.
 
You might like to check out this example that uses the asynchronous methods exposed by the TcpClient and TcpListener classes:

[VB2008/.NET 3.5] Asynchronous TcpListener & TcpClient

In that case the server is a Windows application too but, in a real-world scenario, a server would most likely not be a Windows app or a Console app, but rather a Windows service. In my example I have used asynchronous methods at both the client and server ends but, in your case, your server at least will have to be synchronous, e.g. call AcceptTcpClient rather than BeginAcceptTcpClient. Using synchronous methods is simpler than using asynchronous methods, but asynchronous methods provide more flexibility in certain situations.
 

Latest posts

Back
Top Bottom