Fixed support for UNIX sockets, and fixed static crt-linking for debug builds
This commit is contained in:
parent
893a04b903
commit
f8301d6ee6
@ -43,7 +43,7 @@
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_DEPRECATE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
@ -62,6 +62,7 @@
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="ws2_32.lib comctl32.lib "
|
||||
LinkIncremental="2"
|
||||
GenerateManifest="false"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
@ -71,6 +72,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
EmbedManifest="false"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
|
||||
@ -43,7 +43,7 @@
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
@ -62,6 +62,7 @@
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="d3dx9.lib d3d9.lib"
|
||||
LinkIncremental="2"
|
||||
GenerateManifest="false"
|
||||
GenerateDebugInformation="true"
|
||||
SubSystem="1"
|
||||
TargetMachine="1"
|
||||
@ -71,6 +72,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
EmbedManifest="false"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
|
||||
@ -11,7 +11,12 @@
|
||||
#include <exception>
|
||||
#include <cmath>
|
||||
#include <cassert>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <tchar.h>
|
||||
#else
|
||||
#define TCHAR char
|
||||
#endif
|
||||
|
||||
#include "track.h"
|
||||
|
||||
|
||||
@ -6,6 +6,11 @@
|
||||
#include "data.h"
|
||||
#include "network.h"
|
||||
|
||||
#ifndef REMOTE_HOST
|
||||
#define REMOTE_HOST "localhost"
|
||||
#endif
|
||||
#define REMOTE_PORT 1338
|
||||
|
||||
using namespace sync;
|
||||
|
||||
class ClientDevice : public Device
|
||||
@ -14,8 +19,8 @@ public:
|
||||
ClientDevice(const std::string &baseName, SOCKET serverSocket, Timer &timer) :
|
||||
Device(baseName),
|
||||
timer(timer),
|
||||
serverSocket(serverSocket),
|
||||
serverRow(-1)
|
||||
serverRow(-1),
|
||||
serverSocket(serverSocket)
|
||||
{
|
||||
}
|
||||
|
||||
@ -78,14 +83,13 @@ bool ClientDevice::update(float row)
|
||||
{
|
||||
int track, row;
|
||||
float value;
|
||||
char interp;
|
||||
unsigned char interp;
|
||||
|
||||
recv(serverSocket, (char*)&track, sizeof(int), 0);
|
||||
recv(serverSocket, (char*)&row, sizeof(int), 0);
|
||||
recv(serverSocket, (char*)&value, sizeof(float), 0);
|
||||
recv(serverSocket, (char*)&interp, 1, 0);
|
||||
|
||||
assert(interp >= 0);
|
||||
assert(interp < Track::KeyFrame::IT_COUNT);
|
||||
|
||||
sync::Track &t = syncData.getTrack(track);
|
||||
@ -193,11 +197,14 @@ Device *sync::createDevice(const std::string &baseName, Timer &timer)
|
||||
{
|
||||
if (false == initNetwork()) return NULL;
|
||||
|
||||
struct hostent *myhost = gethostbyname("localhost");
|
||||
struct hostent *host = gethostbyname(REMOTE_HOST);
|
||||
if (NULL == host) return NULL;
|
||||
printf("IP address: %s\n", inet_ntoa(*(struct in_addr*)host->h_addr_list[0]));
|
||||
|
||||
struct sockaddr_in sain;
|
||||
sain.sin_family = AF_INET;
|
||||
sain.sin_port = htons(1338);
|
||||
sain.sin_addr.s_addr= *( (unsigned long *)(myhost->h_addr_list[0]) );
|
||||
sain.sin_port = htons(REMOTE_PORT);
|
||||
sain.sin_addr.s_addr = ((struct in_addr *)(host->h_addr_list[0]))->s_addr;
|
||||
|
||||
// connect to server
|
||||
SOCKET serverSocket = serverConnect(&sain);
|
||||
|
||||
@ -4,18 +4,36 @@
|
||||
|
||||
#include "network.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#ifndef WIN32
|
||||
|
||||
#include "../wifi9.h"
|
||||
#include <nds/jtypes.h>
|
||||
#include <dswifi9.h>
|
||||
#include <netdb.h>
|
||||
|
||||
#endif
|
||||
|
||||
bool initNetwork()
|
||||
{
|
||||
|
||||
#ifdef WIN32
|
||||
WSADATA wsaData;
|
||||
if (0 != WSAStartup(MAKEWORD( 2, 0 ), &wsaData)) return false;
|
||||
if (LOBYTE( wsaData.wVersion ) != 2 || HIBYTE( wsaData.wVersion ) != 0) return false;
|
||||
#endif
|
||||
|
||||
// unix sockets need no init
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void closeNetwork()
|
||||
{
|
||||
#ifdef WIN32
|
||||
WSACleanup();
|
||||
#endif
|
||||
}
|
||||
|
||||
static const char *clientGreeting = "hello, synctracker!";
|
||||
|
||||
@ -5,10 +5,22 @@
|
||||
#ifndef NETWORK_H
|
||||
#define NETWORK_H
|
||||
|
||||
#ifdef WIN32
|
||||
|
||||
#include <winsock2.h>
|
||||
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
|
||||
#include <windows.h>
|
||||
|
||||
#else
|
||||
|
||||
#include <sys/socket.h>
|
||||
#include <netinet/in.h>
|
||||
#include <netdb.h>
|
||||
#define SOCKET int
|
||||
#define INVALID_SOCKET -1
|
||||
|
||||
#endif
|
||||
|
||||
bool initNetwork();
|
||||
void closeNetwork();
|
||||
|
||||
|
||||
@ -165,7 +165,7 @@
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
Detect64BitPortabilityProblems="true"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user