Or if you think this code is unsuitable, than please help me out with this..
here is the code
string clientOrServer;
Stream _stream;
string read;
Stream getTcpStream()
{
TcpClient client;
IPEndPoint meetingPoint = new IPEndPoint(IPAddress.Parse("79.178.57.135"), 8080);
if(clientOrServer.ToLower().StartsWith("c"))
{
client = new TcpClient();
client.Connect(meetingPoint);
}
else
{
TcpListener listener = new TcpListener(meetingPoint.Port);
listener.Start();
client=listener.AcceptTcpClient();
listener.Stop();
}
return client.GetStream();
}
void clientServerclick(System.Windows.Forms.PictureBox picturebox)
{
StreamWriter writer = new StreamWriter(_stream);
writer.AutoFlush = true;
if (picturebox == pictureBox89)
{
writer.WriteLine("{0}", pictureBox89);
}
if (picturebox == pictureBox51)
{
writer.WriteLine("{0}", pictureBox51);
}
}
void readclick()
{
StreamReader reader = new StreamReader(_stream);
string a = reader.ReadLine();
Console.WriteLine(a);
}
this is the code for client generating connection
clientOrServer = "c";
_stream = getTcpStream();
Console.WriteLine("Connected");
server
clientOrServer = "s";
_stream = getTcpStream();
Console.WriteLine("Connected");
this runs when a click on a soldier occurs
clientServerclick(pictureBox);
If this code is off, please guide me on how to accomplish this sort of thing.THANKS

LisaPosted Feb 16, 2009, 9:04 AM
what error are you actually getting
i could help if you post down the error
taking a first look at your code i think you should use a Socket to connect to the Server rather than a TCP Client.
you can always specify the protocol in a socket though.
Thanks,
Lisa