LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   I need some socket programing in C help (https://www.linuxquestions.org/questions/programming-9/i-need-some-socket-programing-in-c-help-389115/)

tomazN 12-04-2005 08:54 AM

I need some socket programing in C help
 
Is it possible to make a two way chat in C client - client, without having a server in between. It would be only suitable for comunication between two users not more. So socket to socket communication. I have done it in java but i have no ideer if this is even possible in C.

Maybe somebody can give me some usefull link, or maybe a simple example how this can be achived if it can be :)

Thx.

FLLinux 12-04-2005 09:46 AM

You can have computer to computer chat in C. But one of the computers is going to have to be the server. Since you have to have someone accept the connect from someone else. If you wanted to just do it with out the server you could do it with UDP, and the two computers would only need to know the IP address of the other computer. But with UDP you are not guarantee that the data will get to the other computer.

vivekr 12-04-2005 10:21 AM

Buddy,
I think chat is a system were both ends act as server and client.
In ur implementation in java I hope u had a streams(both ip and op) associated with sockets on either side thro which they share data and hence both act as said above.

graemef 12-04-2005 10:23 AM

wit cht des he ccaionl doppd caratermater ;)

tomazN 12-04-2005 01:59 PM

Yes i made it so in java (client was a server and vice versa). But i dont know so many C and so i dont know how exactly would i do that. Any help or example or anything appreciated.

anandsba 12-07-2005 11:17 PM

Hi, I suggest you to read Beej guide. You can search for the same in the web.

egag 12-08-2005 11:35 AM

as said take a look at Beej's guide :

http://beej.us/guide/bgnet/output/htmlsingle/bgnet.html

you probably can use this too ( threads ) :

http://www.yolinux.com/TUTORIALS/Lin...ixThreads.html

egag


All times are GMT -5. The time now is 08:27 PM.