Skip to content

Commit

Permalink
scsynth: line option to bind to specific address (tcp)
Browse files Browse the repository at this point in the history
  • Loading branch information
llloret committed May 17, 2016
1 parent 0cd9393 commit 695aea5
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion include/server/SC_WorldOptions.h
Expand Up @@ -105,7 +105,7 @@ SCSYNTH_DLLEXPORT_C struct World* World_New(struct WorldOptions *inOptions);
SCSYNTH_DLLEXPORT_C void World_Cleanup(struct World *inWorld, bool unload_plugins = false);
SCSYNTH_DLLEXPORT_C void World_NonRealTimeSynthesis(struct World *inWorld, struct WorldOptions *inOptions);
SCSYNTH_DLLEXPORT_C int World_OpenUDP(struct World *inWorld, const char *bindTo, int inPort);
SCSYNTH_DLLEXPORT_C int World_OpenTCP(struct World *inWorld, int inPort, int inMaxConnections, int inBacklog);
SCSYNTH_DLLEXPORT_C int World_OpenTCP(struct World *inWorld, const char *bindTo, int inPort, int inMaxConnections, int inBacklog);
SCSYNTH_DLLEXPORT_C void World_WaitForQuit(struct World *inWorld, bool unload_plugins = false);
SCSYNTH_DLLEXPORT_C bool World_SendPacket(struct World *inWorld, int inSize, char *inData, ReplyFunc inFunc);
SCSYNTH_DLLEXPORT_C bool World_SendPacketWithContext(struct World *inWorld, int inSize, char *inData, ReplyFunc inFunc, void *inContext);
Expand Down
10 changes: 5 additions & 5 deletions server/scsynth/SC_ComPort.cpp
Expand Up @@ -401,9 +401,9 @@ class SC_TcpInPort
friend class SC_TcpConnection;

public:
SC_TcpInPort(struct World * world, int inPortNum, int inMaxConnections, int inBacklog):
SC_TcpInPort(struct World * world, std::string bindTo, int inPortNum, int inMaxConnections, int inBacklog):
mWorld(world),
acceptor(ioService, boost::asio::ip::tcp::endpoint(boost::asio::ip::tcp::v4(), inPortNum)),
acceptor(ioService, boost::asio::ip::tcp::endpoint(boost::asio::ip::address::from_string(bindTo), inPortNum)),
mAvailableConnections(inMaxConnections)
{
// FIXME: backlog???
Expand Down Expand Up @@ -513,7 +513,7 @@ SCSYNTH_DLLEXPORT_C bool World_SendPacket(World *inWorld, int inSize, char *inDa
return World_SendPacketWithContext(inWorld, inSize, inData, inFunc, 0);
}

SCSYNTH_DLLEXPORT_C int World_OpenUDP(struct World *inWorld, const char* bindTo, int inPort)
SCSYNTH_DLLEXPORT_C int World_OpenUDP(struct World *inWorld, const char *bindTo, int inPort)
{
try {
new SC_UdpInPort(inWorld, bindTo, inPort);
Expand All @@ -525,10 +525,10 @@ SCSYNTH_DLLEXPORT_C int World_OpenUDP(struct World *inWorld, const char* bindTo,
return false;
}

SCSYNTH_DLLEXPORT_C int World_OpenTCP(struct World *inWorld, int inPort, int inMaxConnections, int inBacklog)
SCSYNTH_DLLEXPORT_C int World_OpenTCP(struct World *inWorld, const char *bindTo, int inPort, int inMaxConnections, int inBacklog)
{
try {
new SC_TcpInPort(inWorld, inPort, inMaxConnections, inBacklog);
new SC_TcpInPort(inWorld, bindTo, inPort, inMaxConnections, inBacklog);
return true;
} catch (std::exception& exc) {
scprintf("Exception in World_OpenTCP: %s\n", exc.what());
Expand Down
2 changes: 1 addition & 1 deletion server/scsynth/scsynth_main.cpp
Expand Up @@ -350,7 +350,7 @@ int main(int argc, char* argv[])
}
}
if (tcpPortNum >= 0) {
if (!World_OpenTCP(world, tcpPortNum, options.mMaxLogins, 8)) {
if (!World_OpenTCP(world, bindTo.c_str(), tcpPortNum, options.mMaxLogins, 8)) {
World_Cleanup(world,true);
return 1;
}
Expand Down

0 comments on commit 695aea5

Please sign in to comment.