Saturday, 31 August 2013

C# Socket and Stream

C# Socket and Stream

I was asking if there is any possible way to get Stream of a Socket class
(like TcpClient class : TcpClient.GetStream()), what i'm trying to do is
to make this code to work with Socket class :
TcpClient imgSender = new TcpClient("IP", port);
BinaryFormatter formatter = new BinaryFormatter();
using (NetworkStream stream = imgSender.GetStream())
{
formatter.Serialize(stream, CaptureDesktop());
}
My actual code :
BinaryFormatter formatter = new BinaryFormatter();
using (var stream = new NetworkStream(_clientSocket))
{
formatter.Serialize(stream, "S1|"+CaptureDesktop());
}
But it doesn't work, i don't get any error, but i don't receive the S1
packet. Any idea ? Thank's. PS : I'm new in C# world so sorry if I'm kind
of newbie.
*EDIT : * _clientSocket is the socket which make the connection to the server

No comments:

Post a Comment