I've been using FreeTDS to connect to a Microsoft SQL Server for some time now and it's been working well with the following configuration:
[mydb]
host = 192.168.0.21
port = 1434
database = master
tds version = 8.0
# tsql -S mydb -U user -P password -D master
locale is "en_GB.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Default database being set to master
1> select ##version
2> go
Microsoft SQL Server 2012 (SP1) - 11.0.3128.0 (Intel X86)
Dec 28 2012 19:06:41
Copyright (c) Microsoft Corporation
Express Edition on Windows NT 6.2 <X64> (Build 9200: ) (WOW64)
(1 row affected)
1> exit
Since my production MS Server has multiple instances, I now have to connect to the database using instance instead of port. I tried this with the following configuration:
[mydb]
host = 192.168.0.21
instance = MYINSTANCE
database = master
tds version = 8.0
But I keep getting the following error:
# tsql -S mydb -U user -P password -D master
locale is "en_GB.UTF-8"
locale charset is "UTF-8"
using default charset "UTF-8"
Default database being set to master
16There was a problem connecting to the server
I did a strace on the command and got the following messages:
# strace -S mydb -U user -P password -D master
...
ioctl(3, FIONBIO, [1]) = 0
sendto(3, "\4MYDB\0", 6, 0, {sa_family=AF_INET, sin_port=htons(1434), sin_addr=inet_addr("192.168.0.21")}, 16) = 6
1) = 0 (Timeout)s=POLLIN}], 1, 1000
sendto(3, "\4MYDB\0", 6, 0, {sa_family=AF_INET, sin_port=htons(1434), sin_addr=inet_addr("192.168.0.21")}, 16) = 6
2) = 0 (Timeout)s=POLLIN}], 1, 1000
sendto(3, "\4MYDB\0", 6, 0, {sa_family=AF_INET, sin_port=htons(1434), sin_addr=inet_addr("192.168.0.21")}, 16) = 6
3) = 0 (Timeout)s=POLLIN}], 1, 1000
sendto(3, "\4MYDB\0", 6, 0, {sa_family=AF_INET, sin_port=htons(1434), sin_addr=inet_addr("192.168.0.21")}, 16) = 6
4) = 0 (Timeout)s=POLLIN}], 1, 1000
sendto(3, "\4MYDB\0", 6, 0, {sa_family=AF_INET, sin_port=htons(1434), sin_addr=inet_addr("192.168.0.21")}, 16) = 6
5) = 0 (Timeout)s=POLLIN}], 1, 1000
sendto(3, "\4MYDB\0", 6, 0, {sa_family=AF_INET, sin_port=htons(1434), sin_addr=inet_addr("192.168.0.21")}, 16) = 6
6) = 0 (Timeout)s=POLLIN}], 1, 1000
sendto(3, "\4MYDB\0", 6, 0, {sa_family=AF_INET, sin_port=htons(1434), sin_addr=inet_addr("192.168.0.21")}, 16) = 6
7) = 0 (Timeout)s=POLLIN}], 1, 1000
sendto(3, "\4MYDB\0", 6, 0, {sa_family=AF_INET, sin_port=htons(1434), sin_addr=inet_addr("192.168.0.21")}, 16) = 6
8) = 0 (Timeout)s=POLLIN}], 1, 1000
sendto(3, "\4MYDB\0", 6, 0, {sa_family=AF_INET, sin_port=htons(1434), sin_addr=inet_addr("192.168.0.21")}, 16) = 6
9) = 0 (Timeout)s=POLLIN}], 1, 1000
sendto(3, "\4MYDB\0", 6, 0, {sa_family=AF_INET, sin_port=htons(1434), sin_addr=inet_addr("192.168.0.21")}, 16) = 6
10) = 0 (Timeout)s=POLLIN}], 1, 1000
sendto(3, "\4MYDB\0", 6, 0, {sa_family=AF_INET, sin_port=htons(1434), sin_addr=inet_addr("192.168.0.21")}, 16) = 6
11) = 0 (Timeout)s=POLLIN}], 1, 1000
sendto(3, "\4MYDB\0", 6, 0, {sa_family=AF_INET, sin_port=htons(1434), sin_addr=inet_addr("192.168.0.21")}, 16) = 6
12) = 0 (Timeout)s=POLLIN}], 1, 1000
sendto(3, "\4MYDB\0", 6, 0, {sa_family=AF_INET, sin_port=htons(1434), sin_addr=inet_addr("192.168.0.21")}, 16) = 6
13) = 0 (Timeout)s=POLLIN}], 1, 1000
sendto(3, "\4MYDB\0", 6, 0, {sa_family=AF_INET, sin_port=htons(1434), sin_addr=inet_addr("192.168.0.21")}, 16) = 6
14) = 0 (Timeout)s=POLLIN}], 1, 1000
sendto(3, "\4MYDB\0", 6, 0, {sa_family=AF_INET, sin_port=htons(1434), sin_addr=inet_addr("192.168.0.21")}, 16) = 6
15) = 0 (Timeout)s=POLLIN}], 1, 1000
sendto(3, "\4MYDB\0", 6, 0, {sa_family=AF_INET, sin_port=htons(1434), sin_addr=inet_addr("192.168.0.21")}, 16) = 6
16) = 0 (Timeout)s=POLLIN}], 1, 1000
close(3) = 0
brk(0x11ee000) = 0x11ee000
brk(0x11d6000) = 0x11d6000
write(2, "There was a problem connecting t"..., 45There was a problem connecting to the server
) = 45
exit_group(1) = ?
Does anyone know what could be happening? Any help would be appreciated.
Thanks for your time.
Related
I am using reqwest in rust to do a simple POST action:
let client = reqwest::blocking::Client::new();
let file = File::open("somefile");
let res = client
.post("http://127.0.0.1:5001/api/v0/add")
.body(file)
.send()?;
I got 400 response. So I used wireshark to check the request sent by reqwest. Interestingly, there was none. All I got was the 400 response.
So I used strace, and compared with cURL.
For cURL, I got:
socket(AF_INET6, SOCK_DGRAM, IPPROTO_IP) = 3
socketpair(AF_UNIX, SOCK_STREAM, 0, [3, 4]) = 0
socket(AF_INET, SOCK_STREAM, IPPROTO_IP) = 5
setsockopt(5, SOL_TCP, TCP_NODELAY, [1], 4) = 0
setsockopt(5, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
setsockopt(5, SOL_TCP, TCP_KEEPIDLE, [60], 4) = 0
setsockopt(5, SOL_TCP, TCP_KEEPINTVL, [60], 4) = 0
connect(5, {sa_family=AF_INET, sin_port=htons(5001), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress)
getsockopt(5, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
getpeername(5, {sa_family=AF_INET, sin_port=htons(5001), sin_addr=inet_addr("127.0.0.1")}, [128 => 16]) = 0
getsockname(5, {sa_family=AF_INET, sin_port=htons(59784), sin_addr=inet_addr("127.0.0.1")}, [128 => 16]) = 0
sendto(5, "POST /api/v0/add HTTP/1.1\r\nHost: 127.0.0.1:5001\r\nUser-Agent: curl/7.80.0\r\nAccept: */*\r\nContent-Length: 1720244\r\nContent-Type: multipart/form-data; boundary=------------------------dfd2b9478efb2b2d\r\nExpect: 100-continue\r\n\r\n", 222, MSG_NOSIGNAL, NULL, 0) = 222
recvfrom(5, "HTTP/1.1 100 Continue\r\n\r\n", 102400, 0, NULL, NULL) = 25
and more after.
But for my app, I got:
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP) = 7
connect(7, {sa_family=AF_INET, sin_port=htons(5001), sin_addr=inet_addr("127.0.0.1")}, 16) = -1 EINPROGRESS (Operation now in progress)
getsockopt(7, SOL_SOCKET, SO_ERROR, [0], [4]) = 0
setsockopt(7, SOL_TCP, TCP_NODELAY, [0], 4) = 0
getpeername(7, {sa_family=AF_INET, sin_port=htons(5001), sin_addr=inet_addr("127.0.0.1")}, [128 => 16]) = 0
recvfrom(7, "HTTP/1.1 400 Bad Request\r\nContent-Type: text/plain; charset=utf-8\r\nVary: Origin\r\nX-Content-Type-Options: nosniff\r\nDate: Sat, 04 Dec 2021 13:02:05 GMT\r\nContent-Length: 33\r\n\r\nfile argument 'path' is required\n", 8192, 0, NULL, NULL) = 206
recvfrom(7, 0x7f923c0f0e00, 8192, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
So why is there no sendto call?
The strace calls are the same: strace -f -e trace=network -s 10000 $cmd.
Vim stuck on opening file. That's the ouput with strace. Anyone could advise here?
strace vim test.py
....
poll([{fd=3, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=3, revents=POLLOUT}])
writev(3, [{"l\0\v\0\0\0\22\0\20\0\0\0", 12}, {"", 0}, {"MIT-MAGIC-COOKIE-1", 18}, {"\0\0", 2}, {"\231\r\1\377\"\0025\371\232\264nj%:\32\277", 16}, {"", 0}], 6) = 48
recvfrom(3, 0x2bec270, 8, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
poll([{fd=3, events=POLLIN}], 1, -1
I suffered from this and dig into it a little.
Here comes my log.
09:46:07.386053 socket(AF_INET6, SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP) = 3
09:46:07.386078 setsockopt(3, SOL_TCP, TCP_NODELAY, [1], 4) = 0
09:46:07.386102 setsockopt(3, SOL_SOCKET, SO_KEEPALIVE, [1], 4) = 0
09:46:07.386125 connect(3, {sa_family=AF_INET6, sin6_port=htons(6010), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_flowinfo=htonl(0), sin6_scope_id=0}, 28) = 0
09:46:07.386225 getpeername(3, {sa_family=AF_INET6, sin6_port=htons(6010), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_flowinfo=htonl(0), sin6_scope_id=0}, [124->28]) = 0
09:46:07.386258 uname({sysname="Linux", nodename="localhost.localdomain", ...}) = 0
09:46:07.386324 access("/root/.Xauthority", R_OK) = 0
09:46:07.386385 openat(AT_FDCWD, "/root/.Xauthority", O_RDONLY) = 4
09:46:07.386414 fstat(4, {st_mode=S_IFREG|0600, st_size=469, ...}) = 0
09:46:07.386439 read(4, "\1\0\0\25localhost.localdomain\0\00216\0\22M"..., 4096) = 469
09:46:07.386548 close(4) = 0
09:46:07.386611 getsockname(3, {sa_family=AF_INET6, sin6_port=htons(49466), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_flowinfo=htonl(0), sin6_scope_id=0}, [124->28]) = 0
09:46:07.386688 fcntl(3, F_GETFL) = 0x2 (flags O_RDWR)
09:46:07.386773 fcntl(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0
09:46:07.386831 fcntl(3, F_SETFD, FD_CLOEXEC) = 0
09:46:07.386853 poll([{fd=3, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=3, revents=POLLOUT}])
09:46:07.386968 writev(3, [{iov_base="l\0\v\0\0\0\22\0\20\0\0\0", iov_len=12}, {iov_base="", iov_len=0}, {iov_base="MIT-MAGIC-COOKIE-1", iov_len=18}, {iov_base="\0\0", iov_len=2}, {iov_base="yD\310A\20\2\202\33\232\242~/\351E\260\336", iov_len=16}, {iov_base="", iov_len=0}], 6) = 48
09:46:07.387053 recvfrom(3, 0x561e505ded90, 8, 0, NULL, NULL) = -1 EAGAIN (Resource temporarily unavailable)
09:46:07.387081 poll([{fd=3, events=POLLIN}], 1, -1) = 1 ([{fd=3, revents=POLLIN}])
09:46:09.393095 recvfrom(3, "\1\0\v\0\0\0\362\0", 8, 0, NULL, NULL) = 8
09:46:09.393186 recvfrom(3, "\277B\241\3\0\0\200\0\377\377\37\0\0\1\0\0\16\0\377\377\1\7\0\0 \10\377\20\377\202\0"..., 968, 0, NULL, NULL) = 968
09:46:09.393266 poll([{fd=3, events=POLLIN|POLLOUT}], 1, -1
<<===========type enter when it stucks.
) = 1 ([{fd=3, revents=POLLOUT}])
09:46:09.393314 writev(3, [{iov_base="b\0\5\0\f\0\0\0BIG-REQUESTS", iov_len=20}], 1) = 20
And I gdb it and find the source(https://github.com/stapelberg/libxcb/blob/master/src/xcb_in.c#L267).
And the sad message is there is no issue and it is just waiting for data from xserver.
The workaround will be disable the xterm.
I like the +xterm_clipboard feature so I have to bear it.
I have a strange problem I cannot solve on my own:
Using Delphi 10.3 Rio Enterprise, on Linux (I tried fresh installs of Ubuntu 16.04 and Ubuntu 18.04 Desktop and Ubuntu 18.04 Server with GUI in VMWare Player 15) PAServer crashes with I/O Error 11 every time I start debugging. I can pull the SDK and Delphi deploys all files correctly. But trying to run ends with the crash and Delphi complaining that GDB Server is no longer available. I can run the program on the Linux host by starting it manually (of course without debugging).
It does not depend on the user in Linux, it also happens as root. Also, a non graphic appliation crashes even on non GUI Ubuntu server, always with IO Error 11.
Debugging with PAServer works well on OSX, Android and Windows. I of course tried a dead simple one form project without content with the same results.
I traced the Delphi PAClient with ProcMon, no evidence on that side. Then I tracked the Linux process with strace, which gave me this output:
write(1, "Starting Platform Assistant Serv"..., 49Starting Platform Assistant Server on port 64211
) = 49
write(1, "\n", 1
) = 1
write(1, "Type ? for available commands\n", 30Type ? for available commands
) = 30
socket(PF_INET6, SOCK_STREAM, IPPROTO_IP) = 5
close(5) = 0
socket(PF_INET, SOCK_STREAM, IPPROTO_IP) = 5
getsockopt(5, SOL_SOCKET, SO_TYPE, [1], [4]) = 0
getsockopt(5, SOL_TCP, TCP_NODELAY, [0], [4]) = 0
setsockopt(5, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(5, SOL_SOCKET, SO_REUSEPORT, [1], 4) = 0
bind(5, {sa_family=AF_INET, sin_port=htons(64211), sin_addr=inet_addr("0.0.0.0")}, 16) = 0
getsockname(5, {sa_family=AF_INET, sin_port=htons(64211), sin_addr=inet_addr("0.0.0.0")}, [16]) = 0
setsockopt(5, SOL_TCP, TCP_NODELAY, [1], 4) = 0
socket(PF_INET6, SOCK_STREAM, IPPROTO_IP) = 6
getsockopt(6, SOL_SOCKET, SO_TYPE, [1], [4]) = 0
getsockopt(6, SOL_TCP, TCP_NODELAY, [0], [4]) = 0
setsockopt(6, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(6, SOL_SOCKET, SO_REUSEPORT, [1], 4) = 0
bind(6, {sa_family=AF_INET6, sin6_port=htons(64211), inet_pton(AF_INET6, "::", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, 28) = 0
getsockname(6, {sa_family=AF_INET6, sin6_port=htons(64211), inet_pton(AF_INET6, "::", &sin6_addr), sin6_flowinfo=0, sin6_scope_id=0}, [28]) = 0
setsockopt(6, SOL_TCP, TCP_NODELAY, [1], 4) = 0
listen(5, 15) = 0
mmap(NULL, 8392704, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f8ab39f9000
mprotect(0x7f8ab39f9000, 4096, PROT_NONE) = 0
clone(child_stack=0x7f8ab41f8ff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f8ab41f99d0, tls=0x7f8ab41f9700, child_tidptr=0x7f8ab41f99d0) = 28987
sched_getparam(28987, [0]) = 0
sched_getscheduler(28987) = 0 (SCHED_OTHER)
listen(6, 15) = 0
mmap(NULL, 8392704, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANONYMOUS|MAP_STACK, -1, 0) = 0x7f8ab31f8000
mprotect(0x7f8ab31f8000, 4096, PROT_NONE) = 0
clone(child_stack=0x7f8ab39f7ff0, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7f8ab39f89d0, tls=0x7f8ab39f8700, child_tidptr=0x7f8ab39f89d0) = 28988
sched_getparam(28988, [0]) = 0
sched_getscheduler(28988) = 0 (SCHED_OTHER)
brk(0x1f55000) = 0x1f55000
brk(0x1f76000) = 0x1f76000
brk(0x1f97000) = 0x1f97000
brk(0x1fba000) = 0x1fba000
brk(0x1fdb000) = 0x1fdb000
mmap(NULL, 200704, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8ab82b8000
mmap(NULL, 200704, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f8ab8287000
write(1, ">", 1>) = 1
read(0, 0xe0bf90, 128) = -1 EAGAIN (Resource temporarily unavailable)
read(0, 0xe0bf90, 128) = -1 EAGAIN (Resource temporarily unavailable)
shutdown(5, SHUT_WR) = 0
close(5) = 0
select(4, [3], NULL, NULL, {1, 0}) = 1 (in [3], left {0, 999997})
ioctl(3, FIONREAD, [1]) = 0
read(3, "\0", 1) = 1
select(4, [3], NULL, NULL, {1, 0}) = 1 (in [3], left {0, 817727})
ioctl(3, FIONREAD, [1]) = 0
read(3, "\0", 1) = 1
select(4, [3], NULL, NULL, {1, 0}) = 1 (in [3], left {0, 999997})
ioctl(3, FIONREAD, [1]) = 0
read(3, "\0", 1) = 1
shutdown(6, SHUT_WR) = 0
close(6) = 0
select(4, [3], NULL, NULL, {1, 0}) = 1 (in [3], left {0, 974854})
ioctl(3, FIONREAD, [1]) = 0
read(3, "\0", 1) = 1
shutdown(7, SHUT_WR) = 0
close(7) = 0
shutdown(8, SHUT_WR) = 0
close(8) = 0
select(0, NULL, NULL, NULL, {0, 500000}) = 0 (Timeout)
write(1, "EInOutError: I/O error 11\n", 26EInOutError: I/O error 11
) = 26
Thanks in advance for help!
Please check
https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1813873
Ubuntu kernel 4.15.0-44 introduced this trouble, and Ubuntu will fix this trouble on next kernel update, Mar 4th.
Completely revised answer.
It doesn't seem to be related to vmWare Player 15 but somehow to Ubuntu, 16 as well as 18. In all non Linux OS debugging works and also in Rhedhat 7 and the Debian Stretch.
In Debian 9 I had to use the sdk generated with the Ubuntu machine as some files were missing when generated in Debian. May be easy to solve but the other SDK does its job.
I have a .txt file that has names followed by numbers. For Example
namesToRatings = {}
with open("example.txt") as document:
for line in document:
print(line)
Would output:
Simon
5 0 0 0 0 0 0 1 0 1 -3 5 0 0 0 5 5 0 0 0 0 5 0 0 0 0 0 0 0 0 1 3 0 1 0 -5 0
0 5 5 0 5 5 5 0 5 5 0 0 0 5 5 5 5 -5
John
5 5 0 0 0 0 3 0 0 1 0 5 3 0 5 0 3 3 5 0 0 0 0 0 5 0 0 0 0 0 3 5 0 0 0 0 0 5
-3 0 0 0 5 0 0 0 0 0 0 5 5 0 3 0 0
and so on...
How do I create a dictionary with the key being the name of the person and the value being a list of the numbers following that name?
E.g {Simon : [5, 0, 0, 0, 0,......... 5, 5, -5]
with open("example.txt") as document:
lines = [line for line in document if len(line.strip())]
namesToRatings = {lines[i] : lines[i+1].split(" ") for i in range(0, len(lines), 2)}
print(namesToRatings) # print it, return it from a function, or set it as a global if you really must.
You can use a regex:
import re
di={}
with open('file.txt') as f:
for m in re.finditer(r'^([a-zA-Z]+)\s+([-\d\s]+)', f.read(), re.M):
di[m.group(1)]=m.group(2).split()
Try using the get_close_matches on the difference library.
Save the dictionary words and meanings in a JSON file, then it will be in the Form of a python dictionary.
import json
from difflib import get_close_matches
data=json.load(open('filePath'))
def check_word(word) :
word=word.lower()
for word in data:
return data
If len(get_close_matches(word, data.keys(), cutoff=0.7))>0:
return get_close_matches(word, data.keys(), cutoff=0.7)
You can add more exceptions here...
with open("example.txt") as document:
lines = (line.strip() for line in document)
lines = (line for line in lines if line)
pairs = zip(*[lines]*2)
namesToRatings = {name: [int(x) for x in values.split()] for name, values in pairs}
This version is similar to the list based approach outlined in John's answer, but doesn't require reading the entire file into a list. The zip(*[lines]*2) will split the input (the lines) into pairs. Output:
{
'Simon': [5, 0, 0, 0, 0, 0, 0, 1, 0, 1, -3, 5, 0, 0, 0, 5, 5, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 0, 0, 1, 3, 0, 1, 0, -5, 0, 0, 5, 5, 0, 5, 5, 5, 0, 5, 5, 0, 0, 0, 5, 5, 5, 5, -5],
'John': [5, 5, 0, 0, 0, 0, 3, 0, 0, 1, 0, 5, 3, 0, 5, 0, 3, 3, 5, 0, 0, 0, 0, 0, 5, 0, 0, 0, 0, 0, 3, 5, 0, 0, 0, 0, 0, 5, -3, 0, 0, 0, 5, 0, 0, 0, 0, 0, 0, 5, 5, 0, 3, 0, 0]
}
Strace excerpt (please ignore sending xml to ssh):
dup(12) = 13
getsockname(13, {sa_family=AF_INET, sin_port=htons(46811), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
getsockopt(13, SOL_SOCKET, SO_TYPE, [1], [4]) = 0
fstat(13, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
getsockname(13, {sa_family=AF_INET, sin_port=htons(46811), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
getsockopt(13, SOL_SOCKET, SO_TYPE, [1], [4]) = 0
fcntl(13, F_SETFD, FD_CLOEXEC) = 0
fcntl(13, F_GETFL) = 0x802 (flags O_RDWR|O_NONBLOCK)
fcntl(13, F_SETFL, O_RDWR|O_NONBLOCK) = 0
setsockopt(13, SOL_SOCKET, SO_REUSEADDR, [1], 4) = 0
setsockopt(13, SOL_SOCKET, SO_REUSEPORT, [0], 4) = 0
setsockopt(13, SOL_TCP, TCP_NODELAY, [0], 4) = 0
setsockopt(13, SOL_TCP, TCP_CORK, [0], 4) = 0
fcntl(12, F_GETFL) = 0x802 (flags O_RDWR|O_NONBLOCK)
fcntl(12, F_SETFL, O_RDWR) = 0
close(12) = 0
getpeername(13, {sa_family=AF_INET, sin_port=htons(22), sin_addr=inet_addr("127.0.0.1")}, [16]) = 0
sendto(13, "<stream:stream xmlns:stream='htt"..., 133, MSG_NOSIGNAL, NULL, 0) = 133
read(13, "SSH-2.0-OpenSSH_6.6.1\r\n", 4096) = 23
read(13, <unfinished ...>
(At the end I kill -9 it.)
The read() at the end was blocking; even though O_NONBLOCK was set via fcntl().
How is this possible?
Version info:
$ uname -r
3.16.4-1-ARCH
Because FD 13 is a dup() of FD 12, this line removes your O_NONBLOCK:
fcntl(12, F_SETFL, O_RDWR) = 0