Click to See Complete Forum and Search --> : Hi i just learn C and C socket


karudangto
02-24-2004, 01:04 PM
Hi i just learn C and some C socket programming but still i dun know much and wut commands to use for certain things. I also just learn how to use linux but still blur blur. I wan to learn how to write a UDP and TCP socket. HOpe u all can help guide me to do. I also hope if u guys can help post me some source code so i can see and learn the format and command to write.

Urmm i wan to do this :
1. Create a client that connect to server1.
2. Server1 then connect server2 ask for IP and Files on server2
3. Server1 then choose random file and send IP and filename to client
4. client take the IP and the filename and connect to server2 to get file

eermm i also see a lot of example show UDP examples only 1 way connection and so if a listener UDP use bind to receive msg then if the listener wan to send back the client need to create bind? Then how to send file (normal txt file) using UDP?


Sry i ask 1 whole lot cause i scared i forget hehe.I wan to do this can u all help me? My cousin say i cannot do so i wan to ask ur help to help me do or at least giimie some code example so i can do. He also say my file in server2 cannot exceed 10 files(i dunno wan to do this for wut)

THx a lot ^^

goon12
02-26-2004, 12:40 PM
I think you should check the man ( section 2 ? ) pages for functions like:
send
sendto
recv
recvfrom
read
write
connect
accept

Off the top of my head: I think you need to use sendto() and recvfrom() functions with UDP sockets, because it's "connectionless", unconnected datagrams. Use send and recv over stream sockets.

This link should help you get on your way
http://crankhouse.com/docs/bgnet/

-goon12