Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 12-04-2005, 09:54 AM   #1
Registered: May 2005
Location: Slovenia
Distribution: Suse 10.2 64bit
Posts: 127

Rep: Reputation: 16
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

Old 12-04-2005, 10:46 AM   #2
Registered: Jul 2004
Location: USA
Distribution: Fedora 9, LFS 6.3, Unbuntu 8.04, Slax 6.0.7
Posts: 145

Rep: Reputation: 15
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.
Old 12-04-2005, 11:21 AM   #3
Registered: Nov 2005
Location: Coimbatore,India
Distribution: Fedora Core4
Posts: 68

Rep: Reputation: 15
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.
Old 12-04-2005, 11:23 AM   #4
Senior Member
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
wit cht des he ccaionl doppd caratermater
Old 12-04-2005, 02:59 PM   #5
Registered: May 2005
Location: Slovenia
Distribution: Suse 10.2 64bit
Posts: 127

Original Poster
Rep: Reputation: 16
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.
Old 12-08-2005, 12:17 AM   #6
LQ Newbie
Registered: Dec 2005
Posts: 7

Rep: Reputation: 0
Hi, I suggest you to read Beej guide. You can search for the same in the web.
Old 12-08-2005, 12:35 PM   #7
Senior Member
Registered: Jul 2004
Location: Netherlands
Distribution: Slackware
Posts: 2,721

Rep: Reputation: 52
as said take a look at Beej's guide :

you probably can use this too ( threads ) :



Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
socket: Socket type not supported monindra Fedora - Installation 4 01-14-2008 08:25 AM
getpeername: Socket operation on non-socket KevStA Linux - General 5 04-26-2006 03:11 AM
cannot read data at server socket, though client socket sends it jacques83 Linux - Networking 0 11-15-2005 02:58 PM
Unable to connect to UNIX socket /tmp/.esd/socket error while using grip dr_zayus69 Linux - Software 4 08-23-2005 08:28 PM
Raw Socket Programing djgerbavore Programming 2 08-18-2004 01:58 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:51 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration