SetSockOpt.com – Tech & Development
Developers, need a strong technical brand? setsockopt.com is geek-friendly and recognizable. Secure here: https://www.godaddy.com/en-uk/domainsearch/find?domainToCheck=setsockopt.com

seen from United States

seen from United States
seen from United Kingdom
seen from United States
seen from China
seen from United States
seen from Kazakhstan
seen from United States
seen from United States

seen from Australia

seen from Norway
seen from United States
seen from United States
seen from China

seen from Germany

seen from Australia

seen from Spain

seen from United States
seen from United States

seen from United States
SetSockOpt.com – Tech & Development
Developers, need a strong technical brand? setsockopt.com is geek-friendly and recognizable. Secure here: https://www.godaddy.com/en-uk/domainsearch/find?domainToCheck=setsockopt.com

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Socket Programming Basics
-----------------------------------------------[Python]------------------------------------------------
>>> import socket
>>> tcpSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> tcpSocket.bind((“0.0.0.0”, 8000))
>>> tcpSocket.listen(2)
>>> (client, (ip, port)) = tcpSocket.accept()
---------------------------------------------[Terminal]-----------------------------------------------
root@TheLaughingMan:~# ncat 192.168.1.150 8000
-----------------------------------------------[Python]------------------------------------------------
>>> client
<socket._socketobject object at 0xb74f6e9c>
>>> ip
‘192.168.1.10’
>>> port
1031
>>> client.send(“Give me six hours to chop down a tree and I will spend the first four sharpening the axe.\n”)
89
>>> data = client.recv(2048)
---------------------------------------------[Terminal]-----------------------------------------------
Give me six hours to chop down a tree and I will spend the first four sharpening the axe.
Brilliant!
-----------------------------------------------[Python]------------------------------------------------
>>> data
‘Brilliant!\n’
-----------------------------------------------------------------------------------------------------------
---------------------------------------[Save as Server.py]----------------------------------------
import socket
tcpSocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
tcpSocket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
tcpSocket.bind((“0.0.0.0”, 8000))
tcpSocket.listen(2)
print “Waiting for a Client ... ”
(client, (ip, sock)) = tcpSocket.accept()
print “Received connection from : ”, ip
print “Starting ECHO output .... ”
data = ‘dummy’
while len(data):
data = client.recv(2048)
print “Client sent: ”, data
client.send(data)
print “Closing connection ...”
client.close()
print “Shutting down server ...”
--------------------------------------------[Terminal1]-----------------------------------------------
root@TheLaughingMan:~# python Server.py
Waiting for a Client ...
--------------------------------------------[Terminal2]-----------------------------------------------
root@ThePuppeteer:~# ncat –nv 192.168.1.150 8000
Ncat Version 6.47 ( http://nmap.org/ncat )
Ncat: Connected to 192.168.1.150:8000.
--------------------------------------------[Terminal1]-----------------------------------------------
Received connection from : 192.168.1.10
Starting ECHO output ....
--------------------------------------------[Terminal2]-----------------------------------------------
Give me six hours to chop down a tree and I will spend the first four sharpening the axe.
Give me six hours to chop down a tree and I will spend the first four sharpening the axe.
--------------------------------------------[Terminal1]-----------------------------------------------
Client sent: Give me six hours to chop down a tree and I will spend the first four sharpening the axe.
-----------------------------------------------------------------------------------------------------------
· Create a simple Echo Server to handle 1 client
· Create a Multi-Threaded Echo Server
· Create a Multi-Process Echo Server
· Create a Non-Blocking Multiplexed Echo Server using Select()
Linux socket auto-tunning
I've been struggling the past week with some performance issues in my network code. Our new network code base, built upon libevent 2.x, was giving us half the performance we got with our previous version, based on libevent 1.x. First, I thought it was a problem with the way we handled buffers, as we have switched to the "automatically" handled buffers that libevent provides, but it seems the problem was on some other socket tweaks I added in the middle of the port.
Looking at the tcpdumps, data was been sent in segments with a maximum size of 16Kbytes, and that was not good for sending big files. Even when sendfile() reported that it was sending large chunks of data (300Kbytes or so), the underlying sockets where really sending things on 16Kbytes blocks, reducing the global throughput to unacceptable levels.
Then I re-read this page on TCP tunning, and I found that:
Manually adjusting socket buffer sizes with setsockopt() disables autotuning. Application that are optimized for other operating systems may implicitly defeat Linux autotuning.
And it is true!. Skipping the code like:
int newBufSize = (1024 * 64); ::setsockopt(socket, SOL_SOCKET, SO_RCVBUF, newBufSize, sizeof(newBufSize)) ::setsockopt(socket, SOL_SOCKET, SO_SNDBUF, newBufSize, sizeof(newBufSize))
in our sockets, and only for kernels newer than 2.6.7, results in longer segment sizes and increased performance. Tricky, isn't it?