Use NetworkStream to write to a client
using System;
using System.IO;
using System.Net.Sockets ;
class MainClass
{
public static void Main()
{
TcpListener tcpl = new TcpListener(9999);
tcpl.Start();
for (;;)
{
Socket newSocket = tcpl.AcceptSocket();
if (newSocket.Connected)
{
NetworkStream ns = new NetworkStream(newSocket);
byte[] buf = {1,2,3,4,5,6,7,8,9};
ns.Write(buf, 0, 9);
ns.Flush();
ns.Close();
}
newSocket.Close();
break;
}
}
}
|
HTML code for linking to this page:
Related in same category :
-
-
-
-
-
-
|
|