L
lewi
I started an unmanaged VC++ dlg app that I want to play arround with socket
for Peer to Peer app on my local LAN and I got it connected up the the app
is the same on both computer and creates a listener socket, one(1 Max user
for now) Server socket connection on acception of listener, and 1 client
socket connection. Then I got it also to Send hardcoded CString and Receive
it in the varible window while debugging...
Now on to C# Window app, I am trying to use the Socket class member of
System.Net.Sockets namespace and I gotten to the Point of working with Async
callback for BeginAccept(). Now first I don't know if the next code sample
to defined right for a callback function. Is it?
public void AsyncAcceptCallback(IAsyncResult ar){...}
Now inside this function I need to construct the connection socket obj and I
was able to do that but when setting up
public void AsyncAcceptCallback(IAsyncResult ar)
{
//Local code lines from MSDN
Socket s = (Socket) ar.AsyncState;
Socket s2 = s.EndAccept(ar);
StateObject so2 = new StateObject();
so2.workSocket = s2;
s2.BeginReceive(so2.buffer, 0, StateObject.BUFFER_SIZE,0, new
AsyncCallback(Async_Send_Receive.Read_Callback), so2);
}
When compiling I get the error "The type or namespace name 'StateObject'
could not be found..." so I looked in the index tabMSDN for StateObject and
it wasn't there so I don't know what namespace this is part of or how it
works but I need it for BeginReceive()...
So is AsyncAcceptCallback() defined above correctly and what is StateObject
and what can I do to fix this...
Any help...
for Peer to Peer app on my local LAN and I got it connected up the the app
is the same on both computer and creates a listener socket, one(1 Max user
for now) Server socket connection on acception of listener, and 1 client
socket connection. Then I got it also to Send hardcoded CString and Receive
it in the varible window while debugging...
Now on to C# Window app, I am trying to use the Socket class member of
System.Net.Sockets namespace and I gotten to the Point of working with Async
callback for BeginAccept(). Now first I don't know if the next code sample
to defined right for a callback function. Is it?
public void AsyncAcceptCallback(IAsyncResult ar){...}
Now inside this function I need to construct the connection socket obj and I
was able to do that but when setting up
public void AsyncAcceptCallback(IAsyncResult ar)
{
//Local code lines from MSDN
Socket s = (Socket) ar.AsyncState;
Socket s2 = s.EndAccept(ar);
StateObject so2 = new StateObject();
so2.workSocket = s2;
s2.BeginReceive(so2.buffer, 0, StateObject.BUFFER_SIZE,0, new
AsyncCallback(Async_Send_Receive.Read_Callback), so2);
}
When compiling I get the error "The type or namespace name 'StateObject'
could not be found..." so I looked in the index tabMSDN for StateObject and
it wasn't there so I don't know what namespace this is part of or how it
works but I need it for BeginReceive()...
So is AsyncAcceptCallback() defined above correctly and what is StateObject
and what can I do to fix this...
Any help...