UNIX programming

AznMaverick

Platinum Member
Apr 4, 2001
2,776
0
0
I've been looking on google, but i haven't been able to find good source code on how to program basically a telnet session. Primarily i would just like to be able to connect to a remote system, send data (ascii string is fine), it would be a bonus to be able to receive data. How do i go about doing this?.

Thanks for your help!
 

n0cmonkey

Elite Member
Jun 10, 2001
42,936
1
0
Look at netcat.

There's plenty of source code out there, so finding an example shouldn't be difficult. :p
 

znaps

Senior member
Jan 15, 2004
414
0
0
There are lots of examples in Java out there. Which language do you want to use?
 

AznMaverick

Platinum Member
Apr 4, 2001
2,776
0
0
i'm most familiar with C. I thought i would be able to do it in C++, but i forgot how to deal with C++.
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Two threads, one reads stdin and writes it to the socket, one reads the socket and writes it to stdout (or alternative files, if you so choose). It's pretty simple.
 

Nothinman

Elite Member
Sep 14, 2001
30,672
0
0
connect()
read()
write()
select()

If you're looking for scripting, use netcat.
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: kamper
Two threads, one reads stdin and writes it to the socket, one reads the socket and writes it to stdout (or alternative files, if you so choose). It's pretty simple.

Threads aren't very "unixy."

Besides being evil. :p

(actually, probably *because* they're evil)
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Originally posted by: BingBongWongFooey
Originally posted by: kamper
Two threads, one reads stdin and writes it to the socket, one reads the socket and writes it to stdout (or alternative files, if you so choose). It's pretty simple.

Threads aren't very "unixy."

Besides being evil. :p

(actually, probably *because* they're evil)
Better than polling...
 

Barnaby W. Füi

Elite Member
Aug 14, 2001
12,343
0
0
Originally posted by: kamper
Originally posted by: BingBongWongFooey
Originally posted by: kamper
Two threads, one reads stdin and writes it to the socket, one reads the socket and writes it to stdout (or alternative files, if you so choose). It's pretty simple.

Threads aren't very "unixy."

Besides being evil. :p

(actually, probably *because* they're evil)
Better than polling...

select()
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
And this is where my lack of c and unix knowledge makes me look dumb :eek: What's select()?
 

kamper

Diamond Member
Mar 18, 2003
5,513
0
0
Sorry, I guess I don't spend enough time browsing around for c api documentation :p

otoh, "man select" told me everything I needed to know :eek: