Rename rawsockets module to nativesockets

This change was done to avoid confusion with TCP/IP raw sockets. Native sockets
module represents handling native system low level socket API in general and is
not just limited anyhow to TCP/IP raw sockets.

A stub lib/deprecated/pure/rawsockets.nim module has been added as
compatibility layer for old code using rawsockets, so this change will not
break existing code.
This commit is contained in:
Adam Strzelecki 2015-09-30 13:36:43 +02:00
commit be991ed413
16 changed files with 91 additions and 65 deletions

View file

@ -2,7 +2,7 @@ discard """
file: "tasyncawait.nim"
output: "5000"
"""
import asyncdispatch, rawsockets, net, strutils, os
import asyncdispatch, nativesockets, net, strutils, os
var msgCount = 0
@ -18,7 +18,7 @@ proc sendMessages(client: TAsyncFD) {.async.} =
proc launchSwarm(port: TPort) {.async.} =
for i in 0 .. <swarmSize:
var sock = newAsyncRawSocket()
var sock = newAsyncNativeSocket()
await connect(sock, "localhost", port)
await sendMessages(sock)
@ -38,7 +38,7 @@ proc readMessages(client: TAsyncFD) {.async.} =
doAssert false
proc createServer(port: TPort) {.async.} =
var server = newAsyncRawSocket()
var server = newAsyncNativeSocket()
block:
var name: Sockaddr_in
when defined(windows):

View file

@ -19,7 +19,7 @@ when defined(windows) or defined(nimdoc):
quit("Error: unhandled exception: Connection refused")
else:
proc testAsyncConnect() {.async.} =
var s = newAsyncRawSocket()
var s = newAsyncNativeSocket()
await s.connect(testHost, testPort)

View file

@ -7,7 +7,7 @@ discard """
import
asyncdispatch,
asyncnet,
rawsockets,
nativesockets,
os
@ -21,7 +21,7 @@ when defined(windows) or defined(nimdoc):
quit("Error: unhandled exception: Connection reset by peer")
else:
proc createListenSocket(host: string, port: Port): TAsyncFD =
result = newAsyncRawSocket()
result = newAsyncNativeSocket()
SocketHandle(result).setSockOptInt(SOL_SOCKET, SO_REUSEADDR, 1)