Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
EDAF55
C-camera
Commits
4ad8c9cd
Commit
4ad8c9cd
authored
Oct 26, 2017
by
Sven Gestegård Robertz
Browse files
added UDP to socket readme
parent
d4978bee
Changes
1
Hide whitespace changes
Inline
Side-by-side
socket_examples/README-socket.md
View file @
4ad8c9cd
# Introduction to socket programming in C
This mimimal example consists of two files, a server which replies with
a message to the first client that connects and then exits, and a client
which connects to a server and outputs whatever it receives.
This mimimal example consists of two pars of files for TCP and UDP:
a server which replies with a message to the first client that
connects and then exits, and a client which connects to a server and
outputs whatever it receives. (In the UDP case, the client sends a
datagram and the server echoes it back, as there is no connection
established, so the "client" must start by sending a datagram.
Note that the terms "client" and "server" in the UDP case have a
more vague meaning, where the "client" is the one that takes the initiative
by sending the first datagram.)
See "Socket programming in C" for more details.
To build and run the example, do
`make run`
. See the Makefile for details
An alternative to using simple_client is to use the telnet program to
connect to the server. To do that, start
`simple_server`
in one terminal,
An alternative to using simple_
tcp_
client is to use the telnet program to
connect to the server. To do that, start
`simple_
tcp_
server`
in one terminal,
and then type
`telnet localhost 5000`
in another.
Sometimes,
`telnet`
is a useful tool to look at or debug text-based protocols.
\ No newline at end of file
Sometimes,
`telnet`
is a useful tool to look at or debug text-based protocols
over TCP.
Please note that TCP is connection-based, but not UDP. Thus, when using
UDP, there is nothing like
`listen()`
or
`accept()`
. Instead, you simply
send datagrams using
`sendto()`
or
`sendmsg()`
, and receive datagrams
with
`recvfrom()`
or
`recvmsg()`
. See the manual pages for further information.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment