4.11network-demos-4-10-branchnetwork-demos-4-9-branch
Last change
on this file since 6bfe512 was
e6f3168,
checked in by Joel Sherrill <joel.sherrill@…>, on 04/29/00 at 19:53:34
|
New test from Eric Norum <eric@…> to exercise RPC/XDR.
|
-
Property mode set to
100644
|
File size:
1.2 KB
|
Line | |
---|
1 | /* |
---|
2 | * This server runs on the RTEMS target or on the host machine. |
---|
3 | * |
---|
4 | * W. Eric Norum |
---|
5 | * eric@cls.usask.ca |
---|
6 | */ |
---|
7 | |
---|
8 | #include "msg.h" |
---|
9 | #include <stdio.h> |
---|
10 | #include <stdlib.h> |
---|
11 | #include <rpc/pmap_clnt.h> |
---|
12 | #include <string.h> |
---|
13 | #include <sys/socket.h> |
---|
14 | #include <netinet/in.h> |
---|
15 | |
---|
16 | #include "msg_server.h" |
---|
17 | |
---|
18 | int |
---|
19 | main (int argc, char **argv) |
---|
20 | { |
---|
21 | int sock; |
---|
22 | struct sockaddr_in myAddr; |
---|
23 | SVCXPRT *transp; |
---|
24 | |
---|
25 | /* |
---|
26 | * Create socket |
---|
27 | */ |
---|
28 | sock = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP); |
---|
29 | if (sock < 0) { |
---|
30 | perror ("socket creation problem"); |
---|
31 | return 1; |
---|
32 | } |
---|
33 | |
---|
34 | /* |
---|
35 | * Bind to local address |
---|
36 | */ |
---|
37 | myAddr.sin_family = htons (AF_INET); |
---|
38 | myAddr.sin_port = htons (TCP_PORT); |
---|
39 | myAddr.sin_addr.s_addr = htonl (INADDR_ANY); |
---|
40 | if (bind (sock, (struct sockaddr *)&myAddr, sizeof myAddr) < 0) { |
---|
41 | perror ("bind problem"); |
---|
42 | return 2; |
---|
43 | } |
---|
44 | |
---|
45 | /* |
---|
46 | * Create TCP server |
---|
47 | */ |
---|
48 | transp = svctcp_create(sock, 0, 0); |
---|
49 | if (transp == NULL) { |
---|
50 | fprintf (stderr, "cannot create tcp service."); |
---|
51 | return 1; |
---|
52 | } |
---|
53 | if (!svc_register(transp, MESSAGEPROC, MESSAGEVERS, messageproc_1, 0)) { |
---|
54 | fprintf (stderr, "unable to register (MESSAGEPROC, MESSAGEVERS, tcp).\n"); |
---|
55 | return 3; |
---|
56 | } |
---|
57 | |
---|
58 | /* |
---|
59 | * Run server |
---|
60 | */ |
---|
61 | svc_run (); |
---|
62 | fprintf (stderr, "svc_run returned"); |
---|
63 | return 0; |
---|
64 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.