-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathspawn.ijs
More file actions
55 lines (37 loc) · 822 Bytes
/
spawn.ijs
File metadata and controls
55 lines (37 loc) · 822 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
load'socket'
load 'files'
WSASocket=: 'ws2_32 WSASocketW i i i i *c i i' & cd
Sleep=:'kernel32 Sleep n i' & cd
sendJ=: 'ws2_32 send i i *c i i'
closeJ=: 'ws2_32 closesocket i i' & cd
binarr =: 3!:2
Z =: fread 'shared.txt'
ferase 'shared.txt'
sockh =: WSASocket _1;_1;_1;(binarr Z);0;0
smoutput sockh
sock =: > 0}sockh
smoutput sock
NB. Sleep 50
body=:'<h1>hi</h1>'
T=:'HTTP/1.0 200 OK',CRLF
sent=:sendJ cd sock;T;(#T);0
smoutput sent
T=:'Connection: close',CRLF
sent=:sendJ cd sock;T;(#T);0
T=:'Content-Length: ',(": (# body)), CRLF
sent=:sendJ cd sock;T;(#T);0
smoutput sent
T=:CRLF,body
sent=:sendJ cd sock;T;(#T);0
T=:CRLF
sent=:sendJ cd sock;T;(#T);0
messageLoop =: 3 : 0
msg =. ''
while. msg -.@:-: 'exit' do.
sendJ cd sock;T;(#T);0
Sleep 500
end.
)
smoutput closeJ sock
exit''
NB. messageLoop ''