| Line | |
|---|
| 1 | #include "Message.h"
|
|---|
| 2 |
|
|---|
| 3 | #include "Compiler.h"
|
|---|
| 4 |
|
|---|
| 5 | #if defined WINDOWS
|
|---|
| 6 | #include <winsock2.h>
|
|---|
| 7 | #include <WS2tcpip.h>
|
|---|
| 8 | #elif defined LINUX
|
|---|
| 9 | #include <sys/socket.h>
|
|---|
| 10 | #include <netinet/in.h>
|
|---|
| 11 | #endif
|
|---|
| 12 |
|
|---|
| 13 | #include <iostream>
|
|---|
| 14 |
|
|---|
| 15 | using namespace std;
|
|---|
| 16 |
|
|---|
| 17 | /*
|
|---|
| 18 | int sendMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *dest)
|
|---|
| 19 | {
|
|---|
| 20 | int ret = sendto(sock, (char*)msg, sizeof(NETWORK_MSG), 0, (struct sockaddr *)dest, sizeof(struct sockaddr_in));
|
|---|
| 21 |
|
|---|
| 22 | cout << "Send a message of type " << msg->type << endl;
|
|---|
| 23 |
|
|---|
| 24 | return ret;
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | int receiveMessage(NETWORK_MSG *msg, int sock, struct sockaddr_in *source)
|
|---|
| 28 | {
|
|---|
| 29 | socklen_t socklen = sizeof(struct sockaddr_in);
|
|---|
| 30 |
|
|---|
| 31 | // assume we don't care about the value of socklen
|
|---|
| 32 | int ret = recvfrom(sock, (char*)msg, sizeof(NETWORK_MSG), 0, (struct sockaddr *)source, &socklen);
|
|---|
| 33 |
|
|---|
| 34 | return ret;
|
|---|
| 35 | }
|
|---|
| 36 | */
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.