Skip to content
This repository has been archived by the owner on Aug 10, 2021. It is now read-only.

Commit

Permalink
Functional version
Browse files Browse the repository at this point in the history
  • Loading branch information
olonho committed Oct 22, 2017
1 parent fc4b8e3 commit f9550c7
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions klib/src/platform/windows/posix.def
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package = platform.posix
headers = stdio.h Windef.h Winsock2.h Ws2tcpip.h Ws2def.h io.h math.h
headers = stdio.h winsock.h io.h math.h
compilerOpts = -DUNICODE -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 -DWINAPI_FAMILY=3 \
-Wno-incompatible-pointer-types -Wno-deprecated-declarations -D_INC_WINDOWS
-Wno-incompatible-pointer-types -Wno-deprecated-declarations
noStringConversion = send recv
linkerOpts = -lWs2_32

Expand Down
2 changes: 1 addition & 1 deletion klib/src/platform/windows/windows.def
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package = platform.windows
headers = windows.h commctrl.h dwmapi.h shlobj.h shlwapi.h shobjidl.h \
urlmon.h usp10.h uxtheme.h vfw.h wininet.h
urlmon.h usp10.h uxtheme.h vfw.h wininet.h winsock2.h ws2tcpip.h ws2def.h
compilerOpts = -DUNICODE -DWINVER=0x0601 -D_WIN32_WINNT=0x0601 -DWINAPI_FAMILY=3 \
-Wno-incompatible-pointer-types -Wno-deprecated-declarations
linkerOpts = -lcomctl32 -lcrypt32 -lshlwapi -lshell32 -limm32 -lusp10 -lwininet
Expand Down
5 changes: 4 additions & 1 deletion samples/socket/src/main/kotlin/EchoServer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ fun main(args: Array<String>) {

memScoped {

val buffer = ByteArray(100)
val buffer = ByteArray(1024)
val prefixBuffer = kotlin.text.toUtf8Array("echo: ", 0, 6)
val serverAddr = alloc<sockaddr_in>()

val listenFd = socket(AF_INET, SOCK_STREAM, 0)
Expand Down Expand Up @@ -60,6 +61,8 @@ fun main(args: Array<String>) {
break
}

send(commFd, prefixBuffer.refTo(0), prefixBuffer.size, 0)
.ensureUnixCallResult("write") { it >= 0 }
send(commFd, pinned.addressOf(0), length, 0)
.ensureUnixCallResult("write") { it >= 0 }
}
Expand Down

0 comments on commit f9550c7

Please sign in to comment.