dist intro client/server code

This commit is contained in:
Remzi Arpaci-Dusseau
2019-05-30 12:32:20 -05:00
parent acd67a3a42
commit 7f7c16cd40
6 changed files with 199 additions and 0 deletions

39
dist-intro/udp.h Normal file
View File

@@ -0,0 +1,39 @@
#ifndef __UDP_h__
#define __UDP_h__
//
// includes
//
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
#include <netdb.h>
#include <fcntl.h>
#include <assert.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <sys/socket.h>
#include <sys/time.h>
#include <sys/types.h>
#include <netinet/tcp.h>
#include <netinet/in.h>
//
// prototypes
//
int UDP_Open(int port);
int UDP_Close(int fd);
int UDP_Read(int fd, struct sockaddr_in *addr, char *buffer, int n);
int UDP_Write(int fd, struct sockaddr_in *addr, char *buffer, int n);
int UDP_FillSockAddr(struct sockaddr_in *addr, char *hostName, int port);
#endif // __UDP_h__