jeudi août 09, 2007

jumping sockets

One day I've faced an X-files situation on windows.

(now you should hear the sound tudu..dudu..duduuuu from the trailer,... no ?

...never mind :-)).


One server was listening to connections on a specific address and port. so far so good...

Another instance of that server was launched (bound on the address/port by mistake) and I suddenly

saw a client communication already started with the first server ending with the second one.


As you can imagine : At First I was afraid,..I was petrified...

I scratched my head for days .... (unless you are already bold... don't try :-)).

reading Microsoft documentation for the 23343123 times I found the solution. the reuse address
of windows socket (winsock) has a tiny difference which make a big one in the end. binding a socket
on an address already used is allowed. Not only when the socket just exists like on Unix but at any time.
The second server was stealing the socket on the first.

I am still confused about some details and there are surely some parts which I didn't get
but what I am sure of is that removing the flag SO_REUSEADDR solved my issue.


Usual shell command lines translated for windows

I had to work on windows recently. As a standard Unix guy, I though that

you cannot use command line on windows, you have to install cygwin, mks etc...

I was curious and I've  started to dig into cmd.exe usage. I've discovered that the windows command

line is far from being poor.

For some aspects I would even say that cmd.exe may be not less powerful than sh.

Here is a list of usual command I use translated to windows command tool.

Hope this help someone.

people crying for awk while doing scripting on windows ,  should have a closer look to "FOR /?" :-)

/bin/ls -l

dir /N /Q

grep -i \^bla myfile.txt

findstr /B /I "bla" myfile.txt

grep -v -i \^bla myfile.txt

findstr /V /B /I "bla" myfile.txt

find /tmp -name \*.c | xargs | grep blo

findstr /S blo C:\\\\tmp \*.c

find /tmp -name \*.c

dir /S /B C:\\\\tmp\\\\\*.c

echo $?

echo %ERRORLEVEL%

ls \*.c 2>/dev/null 

dir \*.c 2>NUL

pwd

echo %CD%

echo $0

echo %CMDCMDLINE%

exit 12

exit /B 12

dirname $1

%~p1

basename $1

%~nx1

which $1

%~dp$PATH:1

env | grep TERM

set TERM 2>NUL

su - foo -c command

runas /profile /user:foo command

rsh myHost -l foo command

rexec myHost -l foo command

for file in `find /tmp -name \*.txt`

do

echo `basename $file`

done

for /R C:\\\\TEMP %i in (\*.txt) DO echo %~ni

mount

net use

mount foo:/bar /mnt/bar

net use Z: \\\\foo\\bar [/USER:username /PERSISTENT:NO]

diff file1 file2

fc file1 file2

echo -n "Enter a letter : " ; read foo

set /P foo="Enter a letter : "

shutdown -g 120 -y -i 6

shutdown /r /l /f /dp:0:0


About

Emmanuel Jannetti blog

Search

Archives
« avril 2014
lun.mar.mer.jeu.ven.sam.dim.
 
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
    
       
Today