Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add address to args #30

Merged
merged 1 commit into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion nesper.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.7.6"
version = "0.7.7"
author = "Jaremy Creechley"
description = "Nim wrappers for ESP-IDF (ESP32)"
license = "Apache-2.0"
Expand Down
3 changes: 2 additions & 1 deletion src/nesper/servers/rpc/rpcsocket_json.nim
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ proc rpcMsgPackReadHandler*(srv: TcpServerInfo[RpcRouter], result: ReadyKey, sou
echo("control server: error: socket timeout: ", $sourceClient.getFd().int)


proc startRpcSocketServer*(port: Port; router: var RpcRouter) =
proc startRpcSocketServer*(port: Port; address="", router: var RpcRouter) =
logi(TAG, "starting json rpc server: buffer: %s", $router.buffer)

startSocketServer[RpcRouter](
port,
address=address,
readHandler=rpcMsgPackReadHandler,
writeHandler=rpcMsgPackWriteHandler,
data=router)
Expand Down
3 changes: 2 additions & 1 deletion src/nesper/servers/rpc/rpcsocket_mpack.nim
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ proc rpcMsgPackReadHandler*(srv: TcpServerInfo[RpcRouter], result: ReadyKey, sou
echo("control server: error: socket timeout: ", $sourceClient.getFd().int)


proc startRpcSocketServer*(port: Port; router: var RpcRouter) =
proc startRpcSocketServer*(port: Port; address="", router: var RpcRouter) =
logi(TAG, "starting mpack rpc server: buffer: %s", $router.buffer)

startSocketServer[RpcRouter](
port,
address=address,
readHandler=rpcMsgPackReadHandler,
writeHandler=rpcMsgPackWriteHandler,
data=router)
Expand Down
4 changes: 2 additions & 2 deletions src/nesper/servers/tcpsocket.nim
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ proc echoReadHandler*(srv: TcpServerInfo[string], result: ReadyKey, sourceClient
for cfd, client in srv.clients:
client.sendWrap(data & message & "\r\L")

proc startSocketServer*[T](port: Port, readHandler: TcpServerHandler[T], writeHandler: TcpServerHandler[T], data: var T) =
proc startSocketServer*[T](port: Port, address: string = "", readHandler: TcpServerHandler[T], writeHandler: TcpServerHandler[T], data: var T) =
var server: Socket = newSocket()
var select: Selector[T] = newSelector[T]()

server.setSockOpt(OptReuseAddr, true)
server.getFd().setBlocking(false)
server.bindAddr(port)
server.bindAddr(port, address=address)
server.listen()

logi TAG, "Server: started. Listening to new connections on port: %s", $port
Expand Down
Loading