Click here to Skip to main content
16,004,977 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Parameter is not valid. Pin
Anubhava Dimri27-Sep-09 18:01
Anubhava Dimri27-Sep-09 18:01 
GeneralRe: Parameter is not valid. Pin
Dave Kreskowiak28-Sep-09 0:55
mveDave Kreskowiak28-Sep-09 0:55 
QuestionControversial Topic of Winsck and TCP/IP Connecting Pin
teknozwizard24-Sep-09 20:17
teknozwizard24-Sep-09 20:17 
AnswerRe: Controversial Topic of Winsck and TCP/IP Connecting Pin
Johan Hakkesteegt24-Sep-09 22:53
Johan Hakkesteegt24-Sep-09 22:53 
AnswerRe: Controversial Topic of Winsck and TCP/IP Connecting Pin
Ian Shlasko25-Sep-09 3:36
Ian Shlasko25-Sep-09 3:36 
AnswerRe: Controversial Topic of Winsck and TCP/IP Connecting Pin
Dave Kreskowiak25-Sep-09 3:39
mveDave Kreskowiak25-Sep-09 3:39 
QuestionRe: Controversial Topic of Winsck and TCP/IP Connecting Pin
teknozwizard25-Sep-09 5:12
teknozwizard25-Sep-09 5:12 
AnswerRe: Controversial Topic of Winsck and TCP/IP Connecting Pin
Ian Shlasko25-Sep-09 5:57
Ian Shlasko25-Sep-09 5:57 
The general rule is that when you're programming a .NET language, try to stay within the .NET framework and .NET-based libraries (aka "Managed code") unless you really need to do otherwise. Hence, don't use winsock directly. Use a TcpClient. The winsock DLLs are pretty much obsolete anyway, I believe.

I do suggest, though, that if this is your first foray into programming, you pick a simpler project. Network clients aren't incredibly complicated, but they pull in several concepts that are a little above the beginner level.

Here's the brief summary of what you need to do:

1) Get the network stream from the GetStream() function. This is an abstraction of the "pipe" you use to read and write data from the network.

2) To simplify access to this stream, create a System.IO.StreamReader. This does all the work of buffering the incoming data, splitting it into discrete messages, and letting you read one line at a time.

3) Create a background thread to watch the streamreader and read the incoming data. Look up System.Threading.ThreadPool.QueueUserWorkItem for a "safe" way to do it. If you're not familiar with the concept, having an extra thread is basically like running two parts of the program at the same time (Sort of). The background thread will keep watching the network for incoming data.

4) Have the background thread loop on the streamreader's ReadLine() function, to get the actual data.

5) When it gets a line, Invoke to the GUI thread (This is needed, because background threads can't touch GUI controls) and add the line to your text box.

Those five steps will let you see the data coming in from the network... Sending data is actually a lot easier...

1) Create a StreamWriter on the same stream in the first step above.

2) When the user presses enter in the input box, grab the text from that box and use the StreamWriter's WriteLine() method, followed by Flush() (Flush makes sure the data actually gets sent, instead of waiting in a buffer).

3) Also add that text to the output window, since MUD clients expect you to echo the data you send.

I've bolded some of the keywords, so you know what to look up in your references... But like I said, this is a bit above beginner level, so take your time and keep google handy.

Proud to have finally moved to the A-Ark. Which one are you in?
Developer, Author (Guardians of Xen)

GeneralRe: Controversial Topic of Winsck and TCP/IP Connecting Pin
teknozwizard25-Sep-09 9:23
teknozwizard25-Sep-09 9:23 
GeneralRe: Controversial Topic of Winsck and TCP/IP Connecting Pin
Ian Shlasko25-Sep-09 11:08
Ian Shlasko25-Sep-09 11:08 
Questionlistview Pin
paya1pa24-Sep-09 19:39
paya1pa24-Sep-09 19:39 
AnswerRe: listview Pin
Christian Graus24-Sep-09 19:47
protectorChristian Graus24-Sep-09 19:47 
AnswerRe: listview Pin
Paramhans Dubey25-Sep-09 0:22
professionalParamhans Dubey25-Sep-09 0:22 
QuestionDevice Programming Pin
structures8324-Sep-09 19:19
structures8324-Sep-09 19:19 
AnswerRe: Device Programming Pin
Christian Graus24-Sep-09 19:48
protectorChristian Graus24-Sep-09 19:48 
AnswerRe: Device Programming Pin
Dave Kreskowiak25-Sep-09 3:32
mveDave Kreskowiak25-Sep-09 3:32 
QuestionAttached an Exe file in a mail and not able to find at destination pc. Pin
r_mohd24-Sep-09 13:48
r_mohd24-Sep-09 13:48 
AnswerRe: Attached an Exe file in a mail and not able to find at destination pc. Pin
Christian Graus24-Sep-09 13:59
protectorChristian Graus24-Sep-09 13:59 
AnswerRe: Attached an Exe file in a mail and not able to find at destination pc. Pin
Luc Pattyn24-Sep-09 14:57
sitebuilderLuc Pattyn24-Sep-09 14:57 
Question.NET memory encreasing (GetBitmapBits) Pin
Colin Raaijmakers24-Sep-09 9:56
Colin Raaijmakers24-Sep-09 9:56 
AnswerRe: .NET memory encreasing (GetBitmapBits) Pin
Luc Pattyn24-Sep-09 10:05
sitebuilderLuc Pattyn24-Sep-09 10:05 
AnswerRe: .NET memory encreasing (GetBitmapBits) Pin
freakyit25-Sep-09 5:01
freakyit25-Sep-09 5:01 
GeneralRe: .NET memory encreasing (GetBitmapBits) Pin
Colin Raaijmakers25-Sep-09 11:37
Colin Raaijmakers25-Sep-09 11:37 
QuestionCollege Games Competition Pin
maybel 24-Sep-09 9:52
maybel 24-Sep-09 9:52 
AnswerRe: College Games Competition Pin
Dave Kreskowiak24-Sep-09 10:21
mveDave Kreskowiak24-Sep-09 10:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.