clientudp.c
来自「tcp/ip原理的第三卷」· C语言 代码 · 共 38 行
C
38 行
/* clientUDP.c - clientUDP */
#include <sys/types.h>
#include <netinet/in.h>
#include <tiuser.h>
extern int t_errno;
extern char *t_errlist[];
/*------------------------------------------------------------------------
* clientUDP - set up call to a specified UDP service on a specified host
*------------------------------------------------------------------------
*/
int
clientUDP( host, service, ppud )
char *host; /* name of host to which connection is desired */
char *service; /* service associated with the desired port */
struct t_unitdata **ppud;
{
struct sockaddr_in sin;
struct t_unitdata *pud;
int d;
d = clientTLI(host, service, "udp", &sin);
/* Allocate and initialize unit data structure */
pud = (struct t_unitdata *) t_alloc(d, T_UNITDATA,T_ADDR|T_UDATA);
if (pud == 0)
errexit("t_alloc failed: %s\n", t_errlist[t_errno]);
bcopy(&sin, pud->addr.buf, sizeof(sin));
pud->addr.len = sizeof(sin);
*ppud = pud;
return d;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?