TCP IP Listener C# Server Problem

  • Thread starter Thread starter saqsaqPK
  • Start date Start date
S

saqsaqPK

Guest
hi Kindly advise us .

create TCPIP Listener in c# Please provide guide Line .

1. My Listener Received data and close .
2.i want server received data and transfer data to String Variable or copy data to text file .
4.aftter copy string variable value empty
3. Server received data from multiple client currently one client is connected with my server .

below is my code.

public class server
{
public static void Main()
{

try
{
IPAddress ipAd = IPAddress.Parse("127.0.0.1");
// use local m/c IP address, and
// use the same in the client

/* Initializes the Listener */
TcpListener myList = new TcpListener(ipAd, 8001);

/* Start Listeneting at the specified port */
myList.Start();

Console.WriteLine("The server is running at port 8001...");
Console.WriteLine("The local End point is :" +
myList.LocalEndpoint);
Console.WriteLine("Waiting for a connection.....");

Socket s = myList.AcceptSocket();
Console.WriteLine("Connection accepted from " + s.RemoteEndPoint);

byte[] b = new byte[256];
int k = s.Receive(b);
Console.WriteLine("Recieved...");
for (int i = 0; i < k; i++)
Console.Write(Convert.ToChar(b));

* clean up */
s.Close();
myList.Stop();
Console.ReadLine();

}
catch (Exception e)
{
Console.WriteLine("Error..... " + e.StackTrace);
}
}

}

Continue reading...
 

Similar threads

S
Replies
0
Views
118
Skhan07
S
P
Replies
0
Views
176
Policy standard local admin account with Active Di
P
Back
Top