Reputation: 28059
I am trying to connect to a socket and then Read a NetworkStream.
My code is below:
NetworkStream myNetworkStream;
Socket socket;
socket = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.IPv4);
socket.Connect(IPAddress.Parse("8.8.8.8"), 8888);
myNetworkStream = new NetworkStream(socket);
byte[] buffer = new byte[1024];
int offset = 0;
int count = 1024;
myNetworkStream.Read(buffer, offset, count);
When I try to debug the above I get the following error:
The operation is not allowed on non-stream oriented sockets.
What am I doing wrong?
Thanks
Upvotes: 1
Views: 3788
Reputation: 61
use this it will work "Socket(AddressFamily.InterNetwork,SocketType.Stream, ProtocolType.Unspecified)"
Upvotes: 0