#include <linux/module.h>
#include <linux/kernel.h>
#include "lwip/ip_addr.h"
#include "lwip/sys.h"
#include "lwip/sockets.h"
#include "lwip/inet.h"
Include dependency graph for sock_tcp_client.c:
Go to the source code of this file.
Defines | |
#define | LOCAL_PORT 10 |
#define | REMOTE_PORT 7 |
#define | REMOTE_SERVER "158.42.58.139" |
#define | SEND_PHRASE "MOOOOLA" |
Functions | |
void | sock_udpclient (void *arg) |
int | init_module (void) |
void | cleanup_module (void) |
|
Definition at line 19 of file sock_tcp_client.c. Referenced by sock_udpclient(). |
|
Definition at line 20 of file sock_tcp_client.c. Referenced by sock_udpclient(). |
|
Definition at line 21 of file sock_tcp_client.c. Referenced by sock_udpclient(). |
|
Definition at line 22 of file sock_tcp_client.c. Referenced by sock_udpclient(). |
|
Definition at line 71 of file sock_tcp_client.c.
00071 {
00072 printk("\n Socket TCP echo client module removed\n");
00073 }
|
|
Definition at line 64 of file sock_tcp_client.c. References NULL, sock_udpclient(), and sys_thread_new().
00064 { 00065 printk("\n\n Socket TCP echo client module inserted\n\n"); 00066 sys_thread_new(sock_udpclient, NULL, 1000); 00067 return 0; 00068 } |
Here is the call graph for this function:
|
Definition at line 25 of file sock_tcp_client.c. References AF_INET, htonl, htons, INADDR_ANY, inet_aton(), LOCAL_PORT, REMOTE_PORT, REMOTE_SERVER, in_addr::s_addr, SEND_PHRASE, sockaddr_in::sin_addr, sockaddr_in::sin_family, sockaddr_in::sin_port, SOCK_STREAM, and sys_thread_exit(). Referenced by init_module().
00025 { 00026 int s, error; 00027 struct sockaddr_in localAddr, servAddr; 00028 struct in_addr addr; 00029 00030 inet_aton(REMOTE_SERVER,&addr); 00031 00032 s = socket(AF_INET, SOCK_STREAM, 0); 00033 00034 /* bind any port number */ 00035 localAddr.sin_family = AF_INET; 00036 localAddr.sin_addr.s_addr = htonl(INADDR_ANY); 00037 localAddr.sin_port = htons(LOCAL_PORT); 00038 00039 error = bind(s, (struct sockaddr *) &localAddr, sizeof(localAddr)); 00040 if(error<0) 00041 rtl_printf("ERROR: cannot bind port TCP %u\n",LOCAL_PORT); 00042 00043 servAddr.sin_family = AF_INET; 00044 servAddr.sin_addr.s_addr = addr.s_addr; 00045 servAddr.sin_port = htons(REMOTE_PORT); 00046 00047 /* connect to server */ 00048 error = connect(s, (struct sockaddr *) &servAddr, sizeof(servAddr)); 00049 if(error<0) 00050 rtl_printf("cannot connect "); 00051 00052 rtl_printf("Socket TCP echo client sending: %s\n",SEND_PHRASE); 00053 error = send(s,SEND_PHRASE , sizeof(SEND_PHRASE), 0); 00054 00055 if(error<0) { 00056 rtl_printf("cannot send data "); 00057 } 00058 00059 close(s); 00060 00061 sys_thread_exit(); 00062 } |
Here is the call graph for this function: