Sockets issue

okibi okibi at ratedo.com
Tue Jan 15 10:33:24 PST 2008


BCS Wrote:

> okibi wrote:
> >>while (true)
> >>{
> >>	Socket clientSocket = soc.accept();
> 
> if it runs to here then you have accepted a connection, if it gets here 
> a second time, you have accepted a second connection.
> 
> >>	Stream str = new SocketStream(clientSocket);
> >>	while(clientSocket.isAlive())
> >>	{
> >>	 	char[] line = str.readLine();
> 
> If this is the loop that is not working then I don't think it is a 
> socket issue. One thing does come to mind, I expect readLine needs to 
> work with CR/LF sets and as I recall a number of cases (telnet and such) 
> don't work exactly as I would expect WRT this. Try testing this inner 
> loop with a file or STDIN.
> 
> >>	 	if (line !is null)
> >>	 		cmdOpen(line);
> >>	}
> >>}
> > 
> > 
> > Thanks for the proper code, however it still doesn't allow a 2nd connection, or any after that for that matter. line defines to null.
> > 
> > Any ideas?

It didn't even occur to me that readLine is waiting for a line break! I'll give it a try and report back.

(this might be a duh! moment)

Thanks!


More information about the Digitalmars-d-learn mailing list