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