-
Notifications
You must be signed in to change notification settings - Fork 0
/
tcpapi.c
49 lines (39 loc) · 1021 Bytes
/
tcpapi.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//__________________________
//| Andrew Lee |
//| CSE5462 Lab 03 |
//| 09-14-16 srbaclib.c |
//|_________________________|
// srbac Library
#include <sys/types.h>
#include <sys/socket.h>
#include <stddef.h>
#include "tcpapi.h"
#include <arpa/inet.h>
// SEND
ssize_t SEND(int sockfd, const void *buffer, size_t len, int flags) {
return sendto(sockfd, buffer, len, flags, (struct sockaddr *)&dest_addr, sizeof(struct sockaddr_in));
}
// RECV
ssize_t RECV(int sockfd, void *buf, size_t len, int flags) {
return recvfrom(sockfd, buf, len, flags, (struct sockaddr *)&return_addr, &return_addrlen);
}
// BIND
int BIND(int sockfd, const struct sockaddr *addr, socklen_t addrlen) {
dest_addr = *addr;
return bind(sockfd, (struct sockaddr *)addr, addrlen);
}
// ACCEPT
void ACCEPT(void) {
}
// CONNECT
void CONNECT(void) {
}
// SOCKET
int SOCKET(int family, int type, int protocol) {
return socket(family, type, protocol);
}
// Set Send Address
void setSendAddress(struct sockaddr dest)
{
dest_addr = dest;
}