LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Client / Server Socket (https://www.linuxquestions.org/questions/programming-9/client-server-socket-4175612098/)

JJJCR 08-16-2017 11:21 PM

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.

rtmistler 08-17-2017 06:42 AM

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.

sundialsvcs 08-17-2017 08:23 AM

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.

JJJCR 08-18-2017 02:32 AM

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.

JJJCR 08-18-2017 02:34 AM

Quote:

Originally Posted by sundialsvcs (Post 5749240)
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.

sundialsvcs 08-18-2017 09:11 AM

Try this link ...

rtmistler 08-18-2017 09:51 AM

Quote:

Originally Posted by JJJCR (Post 5749536)
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.

JJJCR 08-21-2017 01:22 AM

Quote:

Originally Posted by rtmistler (Post 5749634)
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.

JJJCR 08-21-2017 08:25 PM

Quote:

Originally Posted by sundialsvcs (Post 5749616)

Lol, never know about this site: "http://lmgtfy.com"

sundialsvcs 08-25-2017 08:09 PM

Quote:

Originally Posted by JJJCR (Post 5750766)
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. :eek:

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.

JJJCR 09-07-2017 08:42 PM

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.

NevemTeve 09-07-2017 10:11 PM

Could you please explain this?

JJJCR 09-10-2017 08:38 PM

Quote:

Originally Posted by NevemTeve (Post 5756692)
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.

NevemTeve 09-11-2017 05:25 AM

I would say you swapped words 'client' and 'server'

sundialsvcs 09-11-2017 12:00 PM

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 :banghead: ... so that we don't have to do the same.


All times are GMT -5. The time now is 06:23 PM.