Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[C#] Socket I/O

Joined
May 17, 2007
Messages
2,474
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):


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:
ConnectionManager:
 
Custom Title Activated
Loyal Member
Joined
May 18, 2006
Messages
2,065
Reaction score
14
Use StreamReader and StreamWriter classes.
 
Junior Spellweaver
Joined
Sep 15, 2004
Messages
190
Reaction score
0
Code:
NetworkStream nStream = new NetworkStream(socket);
Then use nStream.Read and nStream.Write i suppose.
 
Back
Top