I'm trying to to write an ident server, which yesterday worked fine, but
today its not. When I run it and connect to port 113 and try and send data
as soon as I press a button it dumps the connection, and wont let me send
the whole request, ie (1 , 2). Sometimes it'll send back
System.Byte[] : USERID : UNIX : NICKNAME
No matter what I do cant cant solve it.
[csharp]
using System;
using System.IO;
using System.Net;
using System.Net.Sock ets;
using System.Text;
using System.Threadin g;
namespace IRC.Identd
{
public class Identd
{
private static string username;
private const int IdentdPort = 113;
public static void Start(string UserName)
{
username = UserName;
Thread SocketThread = new Thread(new ThreadStart(Ide ntd.Run));
SocketThread.St art();
}
private static void Run()
{
try
{
string userid = " : USER : UNIX : " + username;
IPEndPoint listenEndPoint = new IPEndPoint(IPAd dress.Any,
IdentdPort);
Socket tcpServer = new Socket(listenEn dPoint.AddressF amily,
SocketType.Stre am, ProtocolType.Tc p);
tcpServer.Bind( listenEndPoint) ;
tcpServer.Liste n(int.MaxValue) ;
// Enter the listening loop.
while (true)
{
// Perform a blocking call to accept requests.
Socket tcpClient = tcpServer.Accep t();
while (true)
{
byte[] buffer = new byte[256];
tcpClient.Recei ve(buffer, 0, tcpClient.Avail able,
SocketFlags.Non e);
byte[] SendBack = Encoding.ASCII. GetBytes(buffer +
userid);
tcpClient.Send( SendBack);
tcpClient.Close ();
}
}
}
catch { }
}
}
}
[/csharp]