[C#] Socket I/O

Joined
May 17, 2007
Messages
2,469
Reaction score
681
Hi,

Lately I've made a switch from Java to C#, cause of the similar functions and syntax (well, for the most part). So far, I'm enjoying the switch and it is a bit easier to program with the VS10 development environment.

So anyways, been trying to find out a similar function of Java's socket read write etc

The following is needed in Java:
Code:
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
And the following in C#:
Code:
using System.IO;
using System.Net.Sockets;
So now, the problem i have is i do not know the read and write functions that are similar to this in C# (this code is in written in java): http://code.theaj.net/15


The two fields in java:
Code:
[LIST=1]
[*]    public [URL="http://www.google.com/search?hl=en&q=allinurl%3AInputStream+java.sun.com&btnI=I%27m%20Feeling%20Lucky"]InputStream[/URL] input;
[*]    public [URL="http://www.google.com/search?hl=en&q=allinurl%3AOutputStream+java.sun.com&btnI=I%27m%20Feeling%20Lucky"]OutputStream[/URL] output;
[/LIST]
Are equal to in C#:
Code:
public Stream mStream
Can anybody telling me the corresponding methods in C# for the following?:
Code:
[LIST=1]
[*]            input = socket.getInputStream();
[*]            output = socket.getOutputStream();
[/LIST]
SocketListener: http://code.theaj.net/16
ConnectionManager: http://code.theaj.net/17
 
Code:
NetworkStream nStream = new NetworkStream(socket);
Then use nStream.Read and nStream.Write i suppose.
 
Back