glibc: socket and fdopen

T

Thomas Jollans

I am playing around with sockets and have the following problem.
I have the socket newsock created by accept(). This code:

FILE *clstream = fdopen ( newsock, "rw" );
fputs ( "message\n", clstream );
fflush ( clstream );

does NOT send anything to the telnet client at the other end. Why? (gcc
3.3.3, glibc 2.3.3)

Thomas Jollans
 
K

Keith Thompson

Thomas Jollans said:
I am playing around with sockets and have the following problem.
I have the socket newsock created by accept(). This code:

FILE *clstream = fdopen ( newsock, "rw" );
fputs ( "message\n", clstream );
fflush ( clstream );

does NOT send anything to the telnet client at the other end. Why?
(gcc 3.3.3, glibc 2.3.3)

This is off-topic for comp.lang.c; followups redirected. (It may be
off-topic in some of the remaining newsgroups as well; a shotgun
approach like this is seldom a good idea.)

BTW, when I compile the above lines I get multiple syntax errors. If
you provide a small complete program that exhibits the problem, you're
more likely to get answers.
 
I

Igmar Palsenberg

Thomas said:
FILE *clstream = fdopen ( newsock, "rw" );
fputs ( "message\n", clstream );
fflush ( clstream );

does NOT send anything to the telnet client at the other end. Why? (gcc
3.3.3, glibc 2.3.3)

Because streams expect seekable objects.
Thomas Jollans



Igmar
 
J

John Burton

Are you closing the socket properly? By using shutdown and then close?
Probably not your problem, but it could be
 
C

CBFalconer

John said:
Are you closing the socket properly? By using shutdown and then close?
Probably not your problem, but it could be

You commit two errors in your reply. First, the reply is OT on
comp.lang.c, and should not be sent there. Second, you are
top-posting, which is frowned on in the comp.* hierarchy. Your
answer belongs after, or intermixed with, the quoted material
which has been snipped of anything not germane to your reply.
 
J

John Burton

CBFalconer said:
You commit two errors in your reply. First, the reply is OT on
comp.lang.c, and should not be sent there. Second, you are
top-posting, which is frowned on in the comp.* hierarchy. Your
answer belongs after, or intermixed with, the quoted material
which has been snipped of anything not germane to your reply.

Ah yes I forgot why I stopped reading and posting in comp.lang.c
Thanks for reminding me.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top