Last post Jul 11, 2011 10:48 PM by Decker Dong - MSFT
Jul 10, 2011 04:09 PM|stefancelmicsisfant|LINK
i am writing an asp.net web app that listens to some port on local machine, fetches data that arrives on it and displays it in a gridview.
how can i listen / scan a port from my app and get arriving data?
from what i read here, i understand i need to implement a 'network sniffer'?
Jul 10, 2011 04:29 PM|Ken Tucker|LINK
Take a look at sockets
Jul 10, 2011 06:02 PM|stefancelmicsisfant|LINK
good example, allows one to brush on the basics.
but in that example the data sent back to the client is the status code from the server. i want to get back to the client all the data that is being emitted by the server, exactly when it is emitted.
is it possible to do that?
Jul 11, 2011 10:48 PM|decker dong - msft|LINK
My suggestion is that you should serialize the whole DataTable filled with data contents and send with Socket, and then Deserizalize it to fetch data contents.
Here's a sample：
The Key two methods ways are——
public static string SerializeObject(object poObject)
BinaryFormatter loBinFormatter = new BinaryFormatter();
MemoryStream loMs = new MemoryStream();
byte buffer = loMs.ToArray();
string lcRetVal = Convert.ToBase64String(buffer, 0, buffer.Length);
public static object DeserializeObject(string pcString)
object loRetVal = null;
byte buffer = Convert.FromBase64String(pcString);
BinaryFormatter loFormatter = new BinaryFormatter();
MemoryStream loStream = new MemoryStream(buffer, 0, buffer.Length);
loRetVal = loFormatter.Deserialize(loStream);