LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 08-16-2017, 11:21 PM   #1
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,149

Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Cool Client / Server Socket


Hello guys, anyone playing with client and server socket using C or other programming languages?

Any text file or links to share?

Do I need to simulate a local DNS to experiment on client / server scenario?

Thank you.
 
Old 08-17-2017, 06:42 AM   #2
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
My favorite guide Beej's Guide to Network Programming. Contains plenty of examples.

Suggest you use the web search string "client server socket example in C"

You do not need to simulate a local DNS unless you wish to use hostnames. If you use direct IP addressing, you can just client-server away.

Note that client-server can mean many things.

Are you interested in BSD socket programming and the programming in C for Linux or System-V?

Are you interesting in client-server "application" level programming where it uses communications channels, but is architect such that you have a client user which needs to contact a server for centralized data or access?

Things like UDP are sometimes called connectionless because you don't need to "connect" the socket, or you still can perform this action.

Meanwhile TCP you are required to do actions like connect and listen, and these exact examples are what I'm talking about when I mention a web search.
 
1 members found this post helpful.
Old 08-17-2017, 08:23 AM   #3
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,642
Blog Entries: 4

Rep: Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933
Start with simple IP-based sockets where the computer simply connects to itself. Learn about the "select()" call where a computer waits for an incoming connection request, and see what it does to respond. Create another program which tries to connect to it and send, of course, "Hello, World!".

Start by grabbing any example anywhere – in your favorite language – study it, and watch it go.
 
1 members found this post helpful.
Old 08-18-2017, 02:32 AM   #4
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,149

Original Poster
Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Hi Rmistler, thanks for this: "You do not need to simulate a local DNS unless you wish to use hostnames. If you use direct IP addressing, you can just client-server away."

Yes, DNS is just for hostnames. Sometimes, we think too much ans forget basic things. LOL.
 
Old 08-18-2017, 02:34 AM   #5
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,149

Original Poster
Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Lightbulb

Quote:
Originally Posted by sundialsvcs View Post
Start with simple IP-based sockets where the computer simply connects to itself. Learn about the "select()" call where a computer waits for an incoming connection request, and see what it does to respond. Create another program which tries to connect to it and send, of course, "Hello, World!".

Start by grabbing any example anywhere – in your favorite language – study it, and watch it go.
Thanks Sundialsvcs, I want to use C program.
 
Old 08-18-2017, 09:11 AM   #6
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,642
Blog Entries: 4

Rep: Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933
Try this link ...
 
1 members found this post helpful.
Old 08-18-2017, 09:51 AM   #7
rtmistler
Moderator
 
Registered: Mar 2011
Location: USA
Distribution: MINT Debian, Angstrom, SUSE, Ubuntu, Debian
Posts: 9,882
Blog Entries: 13

Rep: Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930Reputation: 4930
Quote:
Originally Posted by JJJCR View Post
Thanks Sundialsvcs, I want to use C program.
For C code, I reiterate the recommendation to refer to Beej's guide. It contains the exact examples you are seeking in code, as well as explains them.
 
1 members found this post helpful.
Old 08-21-2017, 01:22 AM   #8
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,149

Original Poster
Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Lightbulb

Quote:
Originally Posted by rtmistler View Post
For C code, I reiterate the recommendation to refer to Beej's guide. It contains the exact examples you are seeking in code, as well as explains them.
Thanks Rtmistler, yes it looks a good link. It has the basics.
 
Old 08-21-2017, 08:25 PM   #9
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,149

Original Poster
Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Question

Quote:
Originally Posted by sundialsvcs View Post
Lol, never know about this site: "http://lmgtfy.com"
 
Old 08-25-2017, 08:09 PM   #10
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,642
Blog Entries: 4

Rep: Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933
Quote:
Originally Posted by JJJCR View Post
Lol, never know about this site: "http://lmgtfy.com"
I couldn't resist. But also, "when the world really is chock-full of examples," it also goes to show that you don't have to imagine that you're starting from scratch on some kind of voyage-of-discovery. Grab something that someone has already done and shamelessly steal from it.

In this case, especially look for "high-level frameworks." Look for someone who has already built(!) the "low-level plumbing" that you imagine that you must now build.

Always remember, today, that "virtually anything that you think that you 'have to write'" has already been written – and it's out there, waiting for you to find it.

Last edited by sundialsvcs; 08-25-2017 at 08:19 PM.
 
Old 09-07-2017, 08:42 PM   #11
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,149

Original Poster
Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Hello guys, sorry for being naive in sockets.
I was surprised for client and server sockets.

If a client application is already listening from the server application, there is no need for authentication.

The client will do what is programmed to do, by the server app.

Last edited by JJJCR; 09-07-2017 at 08:45 PM. Reason: edit
 
Old 09-07-2017, 10:11 PM   #12
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Could you please explain this?
 
Old 09-10-2017, 08:38 PM   #13
JJJCR
Senior Member
 
Registered: Apr 2010
Posts: 2,149

Original Poster
Rep: Reputation: 449Reputation: 449Reputation: 449Reputation: 449Reputation: 449
Cool

Quote:
Originally Posted by NevemTeve View Post
Could you please explain this?
Just a quick overview, an example.

Server program:
It will connect to port 5689, with IP Address of course.
Once connected to port 5689, tell client to display something or execute anything.
Server needs to know the IP Address of the client.

Client program:
Client program must be running.
Client will listen to port 5689.
Once it detects a connection and it knows that it is from the server program.
The client will display, like. "Hello, i'm connected. I own the system"

5689 has to be open if you're doing the testing behind firewall.
But worst if the program is listening on port 80,53 or 443 which is basically open on all networks.

Last edited by JJJCR; 09-10-2017 at 09:29 PM. Reason: edit
 
Old 09-11-2017, 05:25 AM   #14
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,856
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
I would say you swapped words 'client' and 'server'
 
Old 09-11-2017, 12:00 PM   #15
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,642
Blog Entries: 4

Rep: Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933Reputation: 3933
And I guess that it bears repeating ... "do not do a thing already done!"

For instance, surf to https://github.com and search for "linux client server socket example."

Or, how about "client server engine."

Don't waste your time, these days, "figuring out" something, when today you can in a matter of a few seconds lay your hands on a working example ... or a complete prototype that you can quickly adapt to your specific purposes. We have very(!) much to thank the generous people who have given us, free of charge, the product of their ... so that we don't have to do the same.
 
1 members found this post helpful.
  


Reply

Tags
clientserver, socket



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
Connecting client socket to server socket only once in socket programming srinietrx Programming 5 08-20-2017 11:53 AM
[SOLVED] Not able to connect server socket from client in linux srinietrx Programming 4 10-15-2015 12:26 PM
Tcp/ip socket server and client program - Redhat linux server 5(eclipse CDT) parvathi reddy Linux - Newbie 2 03-16-2014 02:51 AM
cannot read data at server socket, though client socket sends it jacques83 Linux - Networking 0 11-15-2005 01:58 PM
compile the socket server for the client cool hat Linux - Software 0 06-19-2004 01:23 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:45 AM.

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