changed to TCP
This commit is contained in:
@@ -20,36 +20,37 @@
|
|||||||
|
|
||||||
#define MAXBUFSIZE 30
|
#define MAXBUFSIZE 30
|
||||||
|
|
||||||
/* Socket variables */
|
|
||||||
int socketfd, socketfd_send;
|
int socketfd, socketfd_send;
|
||||||
|
|
||||||
/* Address info */
|
|
||||||
struct addrinfo hints, remote_hints;
|
struct addrinfo hints, remote_hints;
|
||||||
struct addrinfo *servinfo, *remote_servinfo; /* points to results */
|
struct addrinfo *servinfo, *remote_servinfo;
|
||||||
|
|
||||||
char *remote_machine, *local_port, *remote_port;
|
char *remote_machine, *local_port, *remote_port;
|
||||||
|
|
||||||
void *input(void *arg) {
|
void *input(void *arg) {
|
||||||
printf("Thread made it!\n");
|
while (1) {
|
||||||
//while (1) {
|
|
||||||
/*
|
/*
|
||||||
* Accept input
|
* Accept input
|
||||||
*/
|
*/
|
||||||
//}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void *sender(void *arg) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
pthread_t input_thread;
|
pthread_t input_thread, send_thread, receive_thread;
|
||||||
char *msg = "Test";
|
char *msg;
|
||||||
struct addrinfo *p, *q;
|
struct addrinfo *p, *q;
|
||||||
int status;
|
int status;
|
||||||
/*
|
int yes = 1;
|
||||||
|
|
||||||
if (argc != 4) {
|
if (argc != 4) {
|
||||||
printf("Wrong number of arguments\n");
|
printf("Wrong number of arguments\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
local_port = argv[1];
|
local_port = argv[1];
|
||||||
remote_machine = argv[2];
|
remote_machine = argv[2];
|
||||||
@@ -57,10 +58,10 @@ int main(int argc, char* argv[]) {
|
|||||||
|
|
||||||
memset(&hints, 0, sizeof(hints));
|
memset(&hints, 0, sizeof(hints));
|
||||||
hints.ai_family = AF_INET;
|
hints.ai_family = AF_INET;
|
||||||
hints.ai_socktype = SOCK_DGRAM;
|
hints.ai_socktype = SOCK_STREAM;
|
||||||
hints.ai_flags = AI_PASSIVE;
|
hints.ai_flags = AI_PASSIVE;
|
||||||
|
|
||||||
if ((status = getaddrinfo(NULL, local_port, &hints, &servinfo)) != 0) {
|
if ((status = getaddrinfo(remote_machine, local_port, &hints, &servinfo)) != 0) {
|
||||||
fprintf(stderr,"getaddrinfo error: %s\n",gai_strerror(status));
|
fprintf(stderr,"getaddrinfo error: %s\n",gai_strerror(status));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -74,9 +75,6 @@ int main(int argc, char* argv[]) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set socket to nonblocking */
|
|
||||||
fcntl(socketfd, F_SETFL, O_NONBLOCK);
|
|
||||||
|
|
||||||
/* Bind */
|
/* Bind */
|
||||||
if (bind(socketfd, servinfo->ai_addr, servinfo->ai_addrlen) == -1) {
|
if (bind(socketfd, servinfo->ai_addr, servinfo->ai_addrlen) == -1) {
|
||||||
close(socketfd);
|
close(socketfd);
|
||||||
@@ -97,7 +95,7 @@ int main(int argc, char* argv[]) {
|
|||||||
/* Get remote info */
|
/* Get remote info */
|
||||||
memset(&remote_hints, 0, sizeof(remote_hints));
|
memset(&remote_hints, 0, sizeof(remote_hints));
|
||||||
remote_hints.ai_family = AF_INET;
|
remote_hints.ai_family = AF_INET;
|
||||||
remote_hints.ai_socktype = SOCK_DGRAM;
|
remote_hints.ai_socktype = SOCK_STREAM;
|
||||||
|
|
||||||
if ((status = getaddrinfo(remote_machine, remote_port, &remote_hints,
|
if ((status = getaddrinfo(remote_machine, remote_port, &remote_hints,
|
||||||
&remote_servinfo)) != 0) {
|
&remote_servinfo)) != 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user