[En-Nut-Discussion] TCP Stream question
Ken Campbell
ken at fraserhouse.com
Sun Oct 26 01:54:57 CEST 2003
Being new to C and C's way of handling streams, I've been
having some real problems :)
Esentially I want to implement an automated Telnet client,
which connects to a messaging server, and then just prints out
to the serial port whatever the server sends, indefinitely.
The messaging server (for now) just spits out a single line (timecode) once
every 5 seconds, and looks like: timecode 102374757 (with a newline at the
end).
I've been using the inetq.c example code as a base, and
trying copying over fragments from the other example files,
with mixed results.
I can get my application to connect to the server no problem.
Here's what I've been using after the connection is open, and
the stream has been successfully created:
for (;;) {
fgets(buff, sizeof(buff), stream);
if ((cp = strchr(buff, '\r')) != 0) *cp = 0;
if ((cp = strchr(buff, '\n')) != 0) *cp = 0;
if (buff[0] == 0) continue;
puts(buff);
}
But this doesn't print anything to the serial port.
I've already tested that the serial stuff works (again,
I'm just using most of the inetq.c code).
I've made slight changes, such as having the fgets line inside
an if or a while loop... no luck...
Any code snipets on how to implement this would be appreciated.
Thanks,
Ken Campbell
More information about the En-Nut-Discussion
mailing list