Linux—Network—Socket—Programming—heartbeat—源代码

https://www.cs.utah.edu/~swalton/listings/sockets/programs/

fj.pngprograms.zip (所有源代码)

The Linux Socket Programming book cites several programs which were too lengthy to include entirely in the text. This page gives you access to all the complete and commented code listings.

Program Source for Book [Complete zip file]
Chapter 1: Introducing the Cookbook Client

simple-client.c Open a port and read server's message.

Chapter 2: TCP/IP Network Language Fluency

test-port-client.c The Simple Client is expanded to include sending a message and selecting any port.

Chapter 3: Different Types of Internet Packets

snooper.c Listen to the packets on the network.

Chapter 4: Sending Messages Between Peers

connected-peer.c Listen to the packets on the network.

connectionless-receiver.c
connectionless-sender.c
Pass messages between programs.

http-client.c Display the reply to an HTTP request.

ttcp-client.c
ttcp-server.c
Send transaction TCP messages (T/TCP) between client and server (Linux does not yet support this protocol).

udp-reconnect.c
udp-server.c
Demonstrates connecting and reconnecting using UDP.

Chapter 6: A Server Primer

html-ls-server.c Creates an HTML page from the directory listing.

simple-server.c Simple echo server.

Chapter 7: Dividing the Load: Multitasking

parent-child.c Trivial task-creation example.

echo-process.c
echo-thread.c
trivial-server.c
Multitasked echo servers.

exec-server.c
ls-server.c
Examples of servers that call exec().

html-ls-server.c
http-dir.c
serverls.c
Various multitasked ls or directory servers.

thread-mutex.c Example showing threads with mutexes.

Chapter 8: Choosing When to Wait for I/O

demand-accept.c Simple on-demand servlet creator.

echo-timeout.c Implementation of a connection timeout.

Chapter 9: Breaking Performance Barriers

bored-child.c Example of servlets that terminate if not enough activity.

capped-servlets.c Creates servlets up to a spoecified point. Keeps the host from overloading.

fair-load.c Balances the servlet load between tasks and select()s.

heartbeat-client.c
heartbeat-server.c
Example of how to manually determine if a server or client drops out.

preforking-servlets.c Creates tasks ahead of time in anticipation of a connection.

servlet-chummer.c An example to solve the dynamic connections and load problem.

servlets-ondemand.c Creates as many servlets as accepted connections.

smart-select.c Combines multitasking with select() system call.

test-server.c General server tester.

urgent-receiver.c
urgent-sender.c
Example of send and receiving urgent (out of band) messages.

Chapter 10: Designing Robust Linux Sockets

restart-example.c Example restarting a wayward process (WARNING: it does not always work!).

sigpipe-client.c
sigpipe-server.c
Example of getting and capturing the EPIPE signal.

Chapter 12: Using Java's Networking API

DatagramIO.java Datagram messenger

SimpleEchoClient.java
SimpleEchoServer.java
Client/server without I/O stream translation.

EchoClient.java
EchoServer.java
Client/server with I/O stream translation.

ObjectReceiver.java
ObjectSender.java
Sending and receiving objects.

SimpleMulticastDestination.java
SimpleMulticastSource.java
Simple multicast example.

SimplePeerDestination.java
SimplePeerSource.java
Simple datagram example.

MessageGroupWindow.java
MessageWindow.java
GUI-based datagram/multicast examples.

ThreadedEchoServer.java Threaded echo server.

WindowChat.java GUI-based socket (TCP) messenger.

ErrorDialog.java General GUI error display.

IPv6Test.java IPv6-support verifier.

Chapter 13: Designing and Using a C++ Socket Framework

socket.cpp
socket.h
Entire C++ framework.

echo-client.cpp
echo-server.cpp
Echo client/server example.

broadcast-peer.cpp
multicast-peer.cpp
Broadcast/multicast examples.

peer-caller.cpp
peer-replier.cpp
Dual program example for datagrams.

peer.cpp Peer-to-peer datagram example.

Chapter 15: Network Encapsulation with Remote Procedure Calls (RPCs)

Time Server Makefile.rpctime This is a very simplified program that demonstrates passing scalar (simple) variables through an RPC connection. The rpcgen program creates all files from the .x file.

rpctime.h

rpctime.x

rpctime_client.c

rpctime_clnt.c

rpctime_server.c

rpctime_svc.c

Process Table Server Makefile.rpcproc This program extends the types to include strings. The program's server opens a pipe to 'ps' and sends the resulting strings to the client. The new XDR file helps with data type conversion.

rpcproc.h

rpcproc.x

rpcproc_client.c

rpcproc_clnt.c

rpcproc_server.c

rpcproc_svc.c

rpcproc_xdr.c

Linked List Server Makefile.rpclist The rpcgen program allows you to create dynamic data types and send them over the communication link. It has some interesting limitations, though, which the book covers in detail.

rpclist.h

rpclist.x

rpclist_client.c

rpclist_clnt.c

rpclist_server.c

rpclist_svc.c

rpclist_xdr.c

List-Process Table Server Makefile.rpcps This program merges the list and proc-table programs to create a fielded, dynamic memory process information query.

rpcps.h

rpcps.x

rpcps_client.c

rpcps_clnt.c

rpcps_server.c

rpcps_svc.c

rpcps_xdr.c

Chapter 16: Adding Security to Network Programs and SSL

ssl_client.c The SSL (with the OpenSSL API) client/server uses the standard socket interface as the starting point, and then, it does the handshaking for a secure connection.

ssl_server.c

Chapter 17: Sharing Messages with Multicast, Broadcast, and Mbone

bcast_client.c Broadcasting, an older method of sharing information uses the network mask to send and receive general messages. Multicast replaces broadcast as a more WAN-friendly solution. Until multicasting is fully supported on the Internet, Mbone acts as a virtual network using IP-over-IP protocols.

dgram_echo.c

mcast_client.c

Chapter 18: The Power of Raw Sockets

myping.c Raw sockets permit you to experiment with nearly zero-level protocols, simplifying custom protocols.

mytrace.c

ping.c

Chapter 19: IPv6: The Next Generation to IP

client_v6.c When written right, converting to IPv6 from IPv4 is very simple and only requires a few changes. These examples show the few changes in socket creation and setup.
<script>window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":"2","bdMiniList":false,"bdPic":"","bdStyle":"0","bdSize":"16"},"share":{}};with(document)0[(getElementsByTagName('head')[0]||body).appendChild(createElement('script')).src='http://bdimg.share.baidu.com/static/api/js/share.js?v=89860593.js?cdnversion='+~(-new Date()/36e5)];</script>
阅读(66) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
评论热议
posted @ 2016-02-01 00:00  张同光  阅读(121)  评论(0)    收藏  举报