| New file |
| | |
| | | #include <assert.h> |
| | | #include "net_mod_server_socket_wrapper.h" |
| | | #include "net_mod_socket_wrapper.h" |
| | | #include "bus_server_socket_wrapper.h" |
| | | |
| | | #include "shm_mm_wrapper.h" |
| | | #include "usg_common.h" |
| | | #include <getopt.h> |
| | | #include "logger_factory.h" |
| | | |
| | | |
| | | |
| | | void sendback(void ** buf, int *size){ |
| | | char sendbuf[512]; |
| | | printf( "server: RECEIVED REQUEST FROM \n "); |
| | | sprintf(sendbuf, "RECEIVED REQUEST \n"); |
| | | // buf 和 size是返回值 |
| | | *buf = sendbuf; |
| | | *size = strlen(sendbuf) + 1; |
| | | return; |
| | | } |
| | | |
| | | void start_reply(int mkey) { |
| | | printf("start reply\n"); |
| | | void *ser = net_mod_socket_open(); |
| | | net_mod_socket_bind(ser, mkey); |
| | | int recvsize; |
| | | void *recvbuf; |
| | | |
| | | int rv; |
| | | int key; |
| | | while(true) { |
| | | rv = net_mod_socket_recvandsend_timeout(ser, &recvbuf, &recvsize, &key, sendback, 2, 2000000 ); |
| | | if(rv == 0) |
| | | free(recvbuf); |
| | | } |
| | | // while ( (rv = net_mod_socket_recvfrom(ser, &recvbuf, &size, &key) ) == 0) { |
| | | // // printf( "server: RECEIVED REQUEST FROM %d NAME %s\n", key, recvbuf); |
| | | // sprintf(sendbuf, "%d RECEIVED %s", net_mod_socket_get_key(ser), (char *)recvbuf); |
| | | // net_mod_socket_sendto(ser, sendbuf, strlen(sendbuf) + 1, key); |
| | | // free(recvbuf); |
| | | // } |
| | | } |
| | | |
| | | |
| | | int main() { |
| | | shm_mm_wrapper_init(512); |
| | | start_reply(100); |
| | | } |