Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

socket programming examples ??

Status
Not open for further replies.

sixtoedsloth

IS-IT--Management
Jan 1, 2002
118
GB
Hi, i have a network attached device which works like this :-

i send it "FS" + \n
it sends a string back which is either 2 bytes long (an error) or 20 ish bytes long ( a valid response)

i would like to write a c program (using cc on sco openserver) to automate this.

does anyone have a basic example of how this might be done!
i have been searching the net for examples but they dont seem to be sco specific.


Regards,

Six
 
There is a very nice primer to programming tcp/ip sockets which contains a large variety of socket examples from
Morgan Kaufman publishing:
"The Pocket Guide to Tcp/Ip Sockets", which I would pick
up if I were you. It's very simple to adapt the code in
the book and is a great small reference.

For your problem I would suggest something like expect
which can provide a higher level interface with plenty of
low level benefits for your purpose.
 
Thanks all, Beej's guide was fantastic.

i now have the program working..

but, you knew there was one didnt you ;->

sometimes i get "broken pipe" as an error mesage
any ideas :-

a) why
b) what i can do about it?

Cheers

Six
 
Try the site pont.net they have a lot of good sample
socket programmes for both C and Java.
You could use them as a basic to refine and modify to your specification.

Good Luck - SriSai
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top