w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
  Home » SOCKETS » Page 1
Multiple clients connecting to same server port at the same time?
Note: UDP doesn't really have a concept of "connect", just sending and receiving packets. (e.g. if making a TCP connection is analogous to making telephone call, then sending a UDP packet is more like mailing a letter). Regarding two sockets arriving at the same UDP port on a server at the same time: the TCP/IP stack keeps a fixed-size receive-buffer for each socket that the server creates, an

Categories : Sockets

C# TCP Server/Client Object Transmission/Serialization/De-Serialization Increasingly Using Memory Help Required
Solution: The problem was the hBitmap was causing memory leak when invoking. Using the finally clause I was able to use externdll to delete the object. [DllImport("gdi32")] static extern int DeleteObject(IntPtr ipObj); public static BitmapSource GetBitmapSource(Bitmap bmp) { IntPtr hBitmap = bmp.GetHbitmap(); System.Windows.Media.Imaging.BitmapSource b; try

Categories : Sockets

socket APIs: why `connect` doesn't return a descriptor?
connect() takes an existing descriptor as input. You create and configure the descriptor first and then connect() it to the server. So there is no need for it to return a new descriptor since you have to create the descriptor beforehand. accept() also takes an existing descriptor as input, however that descriptor represents the listening socket. When a client is accepted, a unique descriptor is

Categories : Sockets

TCP Server on Computer. No connection established
From your information, i would say your problem is you need to set up port forward. VirtualBox and VMware both create virtual machines with the NAT network type by default. If you want to run server software inside a virtual machine, you’ll need to change its network type or forward ports through the virtual NAT. here is a guide that will show you how to Forward ports to virtual machine

Categories : Sockets

Netty send event to sockets
Yes, ChannelHandlerContext is thread-safe and can be cached, so this way of usage is completely ok. See note from "Netty In Action" book, that proves my words: You can keep the ChannelHandlerContext for later use, such as triggering an event outside the handler methods, even from a different Thread.

Categories : Sockets

GCDAsyncSocket on browser connects and disconnects immediately with "Socket closed by remote peer" error
I had the same error as well! After much searching and pulling my hair out I stumbled upon a solution that has something to do with the weak declaration for GCDAsyncSocket, ARC in Swift understands the declaration "__weak" in GCDAsyncSocket.m as an excuse to deallocate the socket as quickly as possible. Search for the keyword "__weak" in your project and remove all the references. found this solu

Categories : Sockets

Is UDP always unreliable?
Yes. Every layer is potentially unreliable, starting with the electrical signalling across your Ethernet cable. (Ever jostled one of those plugs? You can see it in Wireshark logs.) Collisions are virtually impossible to avoid. And in case of congestion, your protocol stack may decide to drop UDP packets. But all that's rather beside the point. UDP is unreliable, but that doesn't mean it can't be

Categories : Sockets

Gunicorn socket disappears
It turns out this was indeed a bug, where eventlet workers would delete the socket when they themselves would restart. The fix has already been merged into master branch, but it has unfortunately not been released yet (version 19.3 still has the problem).

Categories : Sockets

Converting Ip Address to int (in_addr) for SWIG binding
To fix the SWIG binding I needed an unsigned long struct in_addr { unsigned long s_addr; }; Still not sure why, but to fix the reversing i needed to unpack the integer as little endian. sa = struct.unpack("<L",aton)[0]

Categories : Sockets

OpenWRT compilation: how to compile netpoll
Recently I also was trying to do things using NetPoll, but after looking in 2 e-books about Kernel Networking, google, wikipedia, forums, git... I just reached the conclusion that NetPoll is just some of the obscure things inside the Linux Kernel. It is NOT documented anywhere (actually I found a slideshow of 5 years ago, but very outdated and the structures and funcions have changed a little sinc

Categories : Sockets

Bittorent protocol. Multiple downloads between same peers
Yes, it is possible for two peers to use more than one connection, sharing torrents with different InfoHashes at the same time. There are two different cases depending on what type of transport protocol the connection is done over. TCP connection When a bittorrent peer shares over TCP, it opens up a incoming port that is announced to the tracker(s) and that port is the one used to connect to b

Categories : Sockets

Linux Socket & IP_ADD_SOURCE_MEMBERSHIP
From man 7 ip: IP_ADD_SOURCE_MEMBERSHIP (since Linux 2.4.22 / 2.5.68) Join a multicast group and allow receiving data only from a specified source.,,, This means that your first process will not receive packets sent from source 172.10.1.1. But reading further: ... This option can be used multiple times to allow receiving data from more than one source. , w

Categories : Sockets

Raw sockets on NaCl?
You can use TCP and UDP sockets, via the nacl_io library. Look at the nacl_io demo in the Native Client SDK. It can be found in the subdirectory examples/demo/nacl_io_demo. Please note that these sockets APIs are only allowed when running as a Chrome App, not on the open web.

Categories : Sockets

boot2docker shellinit command ended up in error "Error requesting socket: exit status 255"
Finally this solution worked for me. It seems like, it is mandatory to have the localhost assigned to 127.0.0.1 in our hosts file(location is /etc/hosts). The following line should be there in /etc/hosts 127.0.0.1 localhost And do the following. At the end, assign variables as the console shows. boot2docker init boot2docker download boot2docker up

Categories : Sockets

UdpSocket.send_to fails with "invalid argument"
You are binding the socket to localhost (the loopback interface), and then trying to communicate through that socket to an address not on that interface. If you instead bind to 0.0.0.0, it will succeed. This means "all ipv4 interfaces". You can bind to a more specific address if necessary.

Categories : Sockets

Weird functioning of read() in socket programming
Edit: Check the return value of read() iterate over read in case you receive more than you are reading, and keep the whole thing in a larger buffer. Oh and by the way, this is the old way of doing sockets, you should now use getaddrinfo. For a (very very) good tutorial about socket programming, I recommand Beej's guide to skcet programming. Edit 2: There is indeed something I don't understan

Categories : Sockets

Losing Data at TCP transfer
TCP is a stream and there is no guarantee that each send will result in exactly one recv. You need to call send repeatedly until all bytes are sent, and on the other end you need to recv repeatedly as well, appending new data to the end of a buffer on each subsequent successful recv... You cannot ignore the return codes from the send/recv calls, you must use it to know how much data is sent/recvd.

Categories : Sockets

fcopy to copy a file from host to vm using tcl
If you have two filenames (and both are currently visible, which depends on how things are mounted and which is totally out of baseline Tcl's control) use file copy. Otherwise, if you can arrange to get the contents of the file somehow (perhaps by using ssh hostaddress cat) then you use chan copy (which fcopy is the old name for). set srcFD [open |[list ssh hostaddress cat "src/file.ext"] "r"] se

Categories : Sockets

How to capture and forward SNMP messages using WinSNMP?
Sounds like you want to make a Proxy Agent. There are already a great number of such implemented, so in order to avoid reinventing the wheel, do a web search for "windows snmp proxy" and see if you could use one of those products instead.

Categories : Sockets

Zabbix agent windows TIME_WAIT sockets
IMHO it's not a big problem, it's concept how TCP works. Do you have any performance issue because your device has 200 TIME-WAIT connections? If you have a lot of monitored items and your agent is in passive mode, then zabbix server has to create a lot of TCP connections to your agent. TIME-WAIT is almost last state of this TCP connection. TIME_WAIT indicates that this side has closed the connect

Categories : Sockets

Go : socket library to get hostname
The net namespace contains methods to translate hostnames to IP addresses (and a few other calls similar to what's in the Python socket namespace) The call you're probably looking for is net.LookupHost or net.LookupIP; addrs, err := net.LookupHost(hostname)

Categories : Sockets

Erlang: Connect to API with sockets/gen_tcp
It sounds like you need HTTP client library. I do not see any reasons to implement HTTP protocol by your own over TCP-sockets and gen_tcp. Erlang standard library already contains one called httpc. Also there is plenty of third-party http clients for general purposes: lhttpc ibroswe hackney For interaction with API I'd recommend you to take a look at gun. As project page says, it follows next

Categories : Sockets

ClientAbortException: java.net.SocketException: Software caused connection abort: socket write error
You are closing the ServletOutputStream yourself. AFAIK this is not necessary and can cause the message you are seeing. Try commenting out out.close(). Normally, if you did not open a stream, you don't need to close it. Tomcat should take care of this for you.

Categories : Sockets

Tornado on python3
The documentation had a bug, fixed recently. For any version of Python, you can't pass a raw dict to write_headers. Instead you must wrap the dict in an HTTPHeaders object. For Python 3, the message must be a bytes instance. With both fixes: def handle_request(request): message = ("You requested %s " % request.uri).encode('ascii') request.connection.write_headers( httputil.ResponseSt

Categories : Sockets

Go: accept different socket calls in one function
As shown in the article "Writing Web Applications", the example for HandleFunc is: package main import ( "fmt" "net/http" ) func handler(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "Hi there, I love %s!", r.URL.Path[1:]) } func main() { http.HandleFunc("/", handler) http.ListenAndServe(":8080", nil) } You cannot replace a r *http.Request by an r *io.ReadClose

Categories : Sockets

Is there anyway to make TCP socket keep alive when switching to other App?
TCP socket keep alive ... can be switched to other App and connection is still alive I think you mix up concepts. TCP socket keep alive is only to detect loss of connectivity to the peer. What you see with Remote Desktop is that it maintains its own state over multiple TCP connections. But this kind of resuming has to be implemented by the application itself and in a application specific way.

Categories : Sockets

check whether a particular client (with ip1, port1) is connected to socket or not?
It should be pretty obvious how to do this. You are storing client information in a list. So simply loop through the list checking if the ip/port reported by accept() is already in the list, adding it if not. Just make sure to keep the list up to date whenever a client disconnects.

Categories : Sockets

Socket Programming Python
Well, the answer is simple and I may snag some reputation here! You are confusing your general socket with the specific client connection. What you receive from running s.accept() is a tuple which consists of: remote socket connection object and remote socket address. This way you can speak to specific client, by referring to the right connection object. So the fixed could looks like this: impo

Categories : Sockets

Applet is not able open socket connection in JRE 8 was working in JRE 7 and below
there is a clue right at the top, Exception in thread "cth" java.security.AccessControlException: access denied. The code snipit that you posted is fine but we would need to see it in better detail to find out why access is being denied.

Categories : Sockets

How to serialize/deserialize objects sent over the network in Haskell?
To answer the first part of your question (about data serialization), I would say that everything you listed sounds fine. Since you are dealing with pretty big (1MB) serializations, I think that the most important thing is laziness. There is another serialization library, called cereal that has strict serializations, and you wouldn't want that because you'd need to build it up in memory before sen

Categories : Sockets

TCP Socket communication between iOS app and Android app
In Java/Android, PrintWriter.println() writes an OS-specific line break. CRLF is the Windows line break. On Android, it uses LF instead. If the iOS reader only expects CRLF and does not allow LF, it will never be triggered. To force CRLF, use PrintWriter.print() instead: public void sendMessage(String message) { out.print(message + " "); }

Categories : Sockets

Multiple processes listening on a same socket
Yup it is very much possible for multiple processes listening on same port by using fork (). In fact most of the web servers use this to enhance the performance when there is a requirement to receive message from huge number of clients. Just create the listener & fork the processes. Now all the processes will be listening on the same port. Now how they divide the incoming requests among them

Categories : Sockets

Is there any way to use same IP for several requests with GAE Sockets API?
It goes against the way App Engine is meant to work, scale-ability. Spawning instances closets to the consumers and multiple instance will mean different IP's. If you want a static IP you will need to switch to Compute Engine. Its a server VM that can have a static IP address. Or if your 3rd party service can take range you get get them from the link. App Engine does not currently provide a wa

Categories : Sockets

Boost chose between SSL ans TLS
I believe you need to refer OpenSSL documentation, since asio::ssl::context is a thin wrapper for SSL_CTX. Thus ssl::context constructor calls SSL_CTX_new() function with an appropriate method. As well as the ssl::context::set_options() function calls SSL_CTX_set_options() function. In particular, for ssl::context::sslv23 method it would be: SSLv23_method(void), SSLv23_server_method(void),

Categories : Sockets

websocket, http or both?
Use websockets for the following needs, Server data changes frequently Multi-user communication Live feeds etc., Refer this for better understanding on websocket usage.

Categories : Sockets

Socket connection already closed
You are seeing the Connection HTTP header. It reads Connection: close (not closed). And it has nothing to do, directly, with whether your end of the connection has been closed already or not but rather whether the client and server can consider the connection persistent or not.

Categories : Sockets

capturing UDP streaming data
UPD is not a streaming protocol. A UDP read returns you one packet. Packets might be lost, reordered and even duplicated. Your code must deal with that fact. Buffer sizes have nothing to do with the problem.

Categories : Sockets

Improve network code without using goto statement for broken connections cases
You could make error handling the caller's problem and return a special error: var errRetry = errors.New("retry") func Reader(source string, proto string, chOutput chan<- string) error { fmt.Println("Conectando con Source:", source) conn, err := net.Dial(proto, source) if err != nil { return err } defer conn.Close() scanner := bufio.NewScanner(conn) for sc

Categories : Sockets

Windows Phone 8.1 app error calling Windows Phone Silverlight 8.1 new Socket exception
Will, I suspect you cannot use OnNavigatedTo, because the UI is not built yet (and maybe something else, that have to do with the App capabilities on the phone). Would you try to use a button Click event handler to initialize your socket? I have a very similar problem. I am trying to create a pure console application for WP8.1, and my Socket constructor fails the same way.

Categories : Sockets




© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.