buchholz

buchholz

  • NA
  • 34
  • 0

asyncronous network streams?

Oct 22 2003 12:01 PM
i'm coding a small irc client by using a socket, which conencts to the server and assigning a network stream to the server. socket --> networkstream --> streamreader and streamwriter --> string incomingdata = streamreader.ReadLine(); everything works fine until there's nothing to recieve for the reader i.e. there are no chatters writing something an a channel. teh syncronous streamreader blocks the whole application while it recieves (or does not recieve any) data. hence i can't write something with the streamwriter interactively. i already tried to make a asyncronous socket, which writes the recieveddata into a buffer without blockign the rest of the application and without the streamreader but it only read single chars and not strings. but i need to get strings, e.g. for cutting the prefixes out of the recieved data. like :":server.name.com 372 nickname : " where i wan't to remove :server.name.com 372 nickname :". i can write the single chars into a stringbuilder with a size of maybe 100 chars, but it soon begins to cut the prefixes i canna get rid of into pieces. e.g. string1: "restofdata \r\n :server.nam" and then string 2: "e.com 372....andsoon". you can imagine that i can't work much with such substrings. so my question is, is there a way to let the streamreader (not the socket itself) recieve data asynchronously? maybe a tutorial? ;)

Answers (3)