w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
GIO socket client server for multiple clients
The magic should happen within your incoming_callback, returning as fast as possible and pushing the work into another GThread (or even better, a GThreadPool)

Categories : Sockets

How to force multiple clients to leave in socket.io?
Store the clients in an array, as objects. Store the room number and if they own the room in the properties. On the disconnect event, check the ownsroom property of the user in question, and if so, loop through the array searching for other clients where the roomid property matches that of the disconnecting owners. When the if statement for clients[i].roomid == disconnected.roomid is true, call the leave function to drop the connection. var i = 0; while(i < clients.length){ if(clients[i].room == disconnected.room) clients[i].leave(); ++i; }

Categories : Javascript

Socket Connecting and Sending Data Received but not read on ASP.net side from Android
The Read() call on the netStream fills the data into the rcvBuffer, but then you try to get your string from the data buffer... and you read two times before you try to get the string, once before the while and once inside the while. Maybe you can use a do{}while() loop.

Categories : C#

how does socket.io send mess messages across multiple servers?
There are a few ways you can do this. More info in this question. A good explanation of how pub/sub in Redis works is here, in Redis' docs. An explanation of how the paradigm works in general is here, on Wikipedia. Quoting the Redis docs: SUBSCRIBE, UNSUBSCRIBE and PUBLISH implement the Publish/Subscribe messaging paradigm where (citing Wikipedia) senders (publishers) are not programmed to send their messages to specific receivers (subscribers). Rather, published messages are characterized into channels, without knowledge of what (if any) subscribers there may be. Subscribers express interest in one or more channels, and only receive messages that are of interest, without knowledge of what (if any) publishers there are. This decoupling of publishers and subscribers can

Categories : Node Js

Socket IO emitting multiple times (equal to number of clients connected) using sails js
the socket object should be accessible in sails.io on the server side link

Categories : Node Js

socket.io error when connecting from iframe
You have encountered Same Origin Policy. The simplest solution is to run the iframe from the same server. Since you have access to I.T time read up on CORS You will basically have to configure the server to allow XSS from your domain. You can also try something like: document.domain = "intranet" Read up on it here

Categories : Javascript

setsockopt() not returning error when setting a big socket recv buffer
The implementaiton of sock_setsockopt() (which is what the system call setsockopt() ends up calling in the kernel) has a comment as to why setting a too large value does not incur an error. The comment indicates the reason is for compatibility with the original BSD implementation (and thus, for software written for BSD systems to be more easily ported to Linux): /* Don't error on this BSD doesn't and if you think * about it this is right. Otherwise apps have to * play 'guess the biggest size' games. RCVBUF/SNDBUF * are treated in BSD as hints */ Please note that if the maximum size is not exceeded when doing so (and if the minimum value has been satisfied) what is actually stored is double the value that was passed in to SO

Categories : C++

How to handle socket read in C when the remote server closes socket possibly before read is finished?
TCP treats the connection serially, and the reader processes everything in the order that the sender transmitted. When the sender closes the connection, the reader will get an EOF after it has read all the data that was sent, not before.

Categories : C

Multicasting big packet contain all info to multiple clients vs individual packets to targeted clients
One of the major advantages of multicast is scalability so in the future if you tend to have more devices multicast will help. Better to look at multicast vs unicast performance for guidance M. Ebrahimi, M. Daneshtalab, P. Liljeberg, and H. Tenhunen. Performance evaluation of unicast and multicast communication in three-dimensional mesh architectures. In Computer Architecture and Digital Systems (CADS), 2010 15th CSI International Symposium on, pages 161-162, sept. 2010.

Categories : C++

Socket.io - Socket connection between clients
The closest thing that currently exists in some form is not currently part of socket.io. It is called WebRTC and is implemented in Chrome currently. It allows the browser to connect with other browsers. http://www.webrtc.org

Categories : Javascript

how to test x amounts of clients connecting to a php api
For parameterized tests I usually turn to Apache JMeter. It takes a bit of time to set it up, but it will give you great flexibility for stress-testing any kind of service. Refering to your specific needs, you can set up any number of users feed API keys to your requests from an external file define idle times between requests for users via timers randomize timers to have a more lifelike load on your service extract variables from responses via regular expressions use extracted variables in subsequent requests set it up for distributed testing with coordinated requests from several clients All in all, it's a pretty awesome tool.

Categories : PHP

XNA and Lidgren Error: Trying to read past buffer size?
You only write one byte to your packets when you send them: om.Write((byte)PacketTypes.Start); But read two when you receive them: // One read here if (incMsg.ReadByte() == (byte)PacketTypes.Ready) { p1Ready = "Ready"; } // Second read here else if (incMsg.ReadByte() == (byte)PacketTypes.Start) Edit To resolve the issue change your code to this: case NetIncomingMessageType.Data: byte type = incMsg.ReadByte(); // Read one byte only if (type == (byte)PacketTypes.Ready) { p1Ready = "Ready"; } else if (type == (byte)PacketTypes.Start) { CurrentGameState = GameState.City; Console.WriteLine("Game started"); numPlayers = 2; } bre

Categories : Networking

Connecting to old MySQL servers
From mysql_* to PDO isn't really that bad, PDO just seems a little frightening at first, and agreed, is somewhat more complicated, at least for retrieving data from queries (IMO). It might be a bit at first, but it shouldn't be too bad, and it's more secure as well, in addition to being one of the two current standards. For example, $link = mysql_connect('localhost', 'mysql_user', 'mysql_password'); and mysql_query($sql) become $link = new PDO("mysql:host=localhost;dbname=$dbname", $dbuser, $dbpass); and $statement = $link->prepare($sql); $statement->execute(values);

Categories : PHP

Using Vim as a Javascript Sandbox: How do I write a buffer to node and read the result in another buffer?
Pursuant to Randy's comment, utilising vim-slime on top of tmux with the node REPL in the right hand tmux pane does indeed work. This is a pretty valid way to answer this question specifically, although I'm still interested in the vim-contained answer. Although I haven't set it up yet, I plan to make this a specific tmux config managed by tmuxinator.

Categories : Javascript

Haproxy 1.4 connecting to an https backend servers
haproxy 1.4 does not support SSL. Either update to 1.5 or look at using something like stunnel. I have used both in a very large enterprise implementation and both products work well. If you want to stick with haproxy 1.4 then the stunnel route is VERY easy. Simply install stunnel on your haproxy servers, listen on a local port, have haproxy connect to that local port and then configure stunnel to point to the remote https endpoint. Besides global settings in stunnel, the actual config would be 3 lines name listen port on localhost destination host and port

Categories : Ubuntu

Multiple Threads Accessing the socket read causing jvm OutOfMemory Issue
Assume if sender threads waits for particular response from other end. Why? You already have a receiver thread. During that time if any other Testcases (I mean threads) which starts to push their requests and do the execution means, the response receiver thread having the logic of byte[] ofsRes = new byte[size]; Where did the value of size come from? And what exactly is the meaning of the sender thread and the receiver thread both trying to read the response? I don't know what you expect to happen, but what will happen is entirely undefined. This doesn't make any sense. You need to decide who is supposed to read the response, and let them read it. Probably you need to introduce some synchronization between the sender and receiver threads so that the sender doesn't send the nex

Categories : Java

PHP/C++ server to handle socket.io clients
Use an object caching layer like APC or memcached as shared memory, in your PHP backend. That way, you can maintain synchronization between different instances/clients. Bear in mind that you will have to implement some multiprocessing security as this is not thread safe. For instance: /* PHP application 1: */ (($value = apc_fetch("IncrementValue")) != FALSE) ? apc_store("IncrementValue",$value+1) : apc_store("IncrementValue",1); Another can then access it just like this: echo apc_fetch("IncrementValue"); It is a fast although crude way to communicate between sessions.

Categories : PHP

Socket IO Node to broadcast data to all clients
You are using express 2.x syntax. You must change the syntax for express v3. See this page Socket.IO's .listen() method takes an http.Server instance as an argument. As of 3.x, the return value of express() is not an http.Server instance. (See the Application function section above.) To get Socket.IO working with Express 3.x, make sure you manually create and pass your http.Server instance to Socket.IO's .listen() method. This is how you would do it with express3 and socket.io var express = require('express') var http = require('http'); var app = express(); var server = http.createServer(app); var io = require('socket.io').listen(server);

Categories : Javascript

Error in recv()/send() (in Socket) or read()/write() (in CFile)
send does not guarantee to send all the data supplied, nor does recv promise to receive all the data available. You have to call them in a loop, adjusting the amount left as you go, checking the error each time, in order to ensure everything is sent or received. From memory - I always put the loop in these days! - the looping isn't always necessary (I believe it depends on various factors, mostly out of your control), so your code can often appear to work fairly reliably even if you don't have it in. This is touched on in the MSDN documentation for send: If no error occurs, send returns the total number of bytes sent, which can be less than the number requested to be sent in the len parameter.

Categories : Sockets

Socket.io connections distribution between several servers
The first idea - is to tell client side available servers for current time. Furthermore you can generate server list for client side by priority, just put them in javascript generated array by order. This answer means that your servers can answer on any models, you can control server loading by changing servers ordering in generated list for new clients. I think this is more flexible way. But if you want - you can parse query string in nginx and route request on any underlying server - just have a table for "model id-server port" relations Upd: Just thinking about your task. And find one another solution. When you generate client web page you can inline servers count in js somewhere. Then, when you requesting model updates, just use another parameter founded as serverId = modelId%Serv

Categories : Python

Node.js and Socket.IO Not Responding in Some Servers
After talking with you on the #nodejitsu IRC channel, it seems that this may indeed be a problem with your work proxy/firewall. As was suggested to you in the chat last night, you could always try to use secure websocket connections (wss rather than ws) to see if that will allow your connections to pass through. If that doesn't work, you would need to send your connection outside of your work's connection. For instance, proxying into a computer at your home and using your home network while you're at work and want to use websockets.

Categories : Node Js

JavaFX Clients and JDBC Servers: Are JavaFX Bean-style objects required on the server side?
As I've thought more about what it is I'd like to do, I've understood that my approach is far too simplistic. What I think I'm really talking about is a flow from information from the data store to the client that looks closer to this: +-------------------------------+ | DATA STORE (appx 20 tables) | HSQLDB; highly normalized tables +-------------------------------+ | v +-------------------------------+ Receives query result | SERVER/SERVLET REQ PROCESSOR | Transmits as CachedRowSet +-------------------------------+ | (Serialization) | v +-------------------------------+ | CLIENT INTERFACE LAYER | Deserializes query results +-------------------------------+ |

Categories : Java

Socket programming: notify all clients before shutting server down
A TCP socket should not be closed, if the other side hasn't acknowledged all data. This mechanism is designed into most application protocols. For example with HTTP, SMTP, IMAP, POP3, the server signals when the connection should be closed, the client closes the socket and afterwards the server closes the socket. In your case, you can extend your Close method as follows: public void Close() throws IOException { String outputLine = p.processInput("shut"); out.println(outputLine); // signal the client that the connection should be closed socket.shutdownOutput(); // wait on ack by blocking until EOF is received if (in.read() != -1) { throw new RuntimeException("unexpected data sent by client"); } // close socket socket.close(); }

Categories : Java

Sails.js + socket.io: Sending messages from server to clients
The Sails way to do this would be to have a model backing your "Groups", and in a controller action have a socket subscribe to a group with Group.subscribe(groupId, req.socket). Then you can send messages to a specific group with Group.publish(groupId, data). You can also subscribe to an arbitrary room name in a controller using req.listen(groupId), and broadcast to that room with req.broadcast(roomName, data). This is all in the Sails documentation for working with Sockets!

Categories : Node Js

Socket.io memory doesn't drop of after clients disconnect
I've had similar issues with socket.io. It seems that once a client connects, it never gets deleted from socket.io. You can debug the value of SocketIoServer.sockets.sockets. It is an array containing all connected (and disconnected sockets). Maybe that's where your memory leak lies. Also, I just saw that socket.io released version 1.0. You can try it out and see if it has resolved that issue.

Categories : Node Js

Socket IO Rooms: Get list of clients in specific room
Just a few things. when you have the socket you can then set the properties like: socket.nickname = 'Earl'; later to use the save property for example in a console log: console.log(socket.nickname); you where missing a closing quote (') in your: console.log('User joined chat room 1); Im not entirely sure about your loop. Below is the amended code should help you out a bit, also be aware the loop i am using below is asynchronous and this may effect how you handle data transfers. socket.nickname = 'Earl'; socket.join('chatroom1'); console.log('User joined chat room 1'); var roster = io.sockets.clients('chatroom1'); roster.forEach(function(client) { console.log('Username: ' + client.nickname); }); to help you out more i would need to see all your code as this does not give me

Categories : Javascript

How to reduce time difference between clients receiving data in socket.io?
I think you should try the following: make sure (using onLoad events and collecting that events on server with socket.io) that every clients downloaded animation, and then send signal to start it.

Categories : Javascript

Nodejs socket.io is emitting message to client as number of clients connected
You should put server.on('sendingData', function(data){...}); outside socket.on('connection', function (client){...});. This is because the sendingData event is for http server and not socket.io server. Putting it inside socket.io connection handler makes it repeatedly execute for each connected client to socket.io server

Categories : Node Js

Socket closed before able to read from ObjectInputStream(BufferedInputStream(Socket.getInputStream))
You can't use a buffered input stream and another kind of stream on the same socket. The buffered stream will steal data from the other one. Make up your kind the ObjectInputStream will do everything you need. Just use that.

Categories : Java

Multiple Build Folders (multiple clients, mulitask, multiple targets) using Grunt (Yeoman)
There's really no best practice out there beside what's recommended for PG 3. For multiple clients, you may want to modify your gruntjs. This is my project structure, where assets folder contain data for different clients: And here is my gruntjs file. It use ImageMagik to create all the necessary launcher icons. Build and deploy for over the air installation. You get the idea... /*** * Package script for MobileStore ***/ 'use strict'; // require package.json: /* { "name": "MobileStore", "version": "1.0.1", "devDependencies": { "grunt": "~0.4.1", "grunt-contrib-jshint": "~0.6.0", "grunt-contrib-clean": "~0.4.1", "grunt-contrib-copy": "~0.4.1", "grunt-contrib-concat": "~0.3.0", "grunt-exec": "~0.4.2", "grunt-string-replace": "~0.2.4", "grunt

Categories : Javascript

Connecting to a udp socket in Node.js
You need to use the addMembership() method to join a multicast group, in UDP you don't connect to servers, a connection is never created and there is no guarantee that you will receive any/all packets. You join a multicast group and receive packets with that group-id that reach your network card, the python method name is misleading. http://nodejs.org/api/dgram.html#dgram_socket_addmembership_multicastaddress_multicastinterface

Categories : Python

Using buffer for read and read operations examples in Go
Assuming you're talking about IO: Imagine you have a var fin *os.File and that file wrapped in a buffer, var instrm *bufio.Reader. Now imagine you are writing some kind of parser that reads the input one character (lets say byte) at a time. Package bufio implements buffered I/O. If you call myParser.Parse(fin) you will call .Read 4,194,304 times to read each byte, which will make a system call 4,194,304 times, which will cause 4,194,304 context switches. context switches are when control transfers from the userspace program to the OS and are one of the slowest (non-IO) operations. In situations where the OS is not coalescing/prefetching IO requests there is also the horrible possibility your IO device is seeking and reading one byte at a time, but most operating system's IO elevator, pre

Categories : Go

node.js/ Getting buffer on data.socket
According to the docs, you must specify the encoding with the setEncoding() method to receive an string. If you don't, you'll receive an Buffer with raw data because Node will not know what encoding you want - and Node deals with very low level networking. For example: var server = net.createServer(function(socket) { socket.setEncoding("utf8"); socket.on('data', function(d) { console.log(d); // will be string } }

Categories : Node Js

Socket Buffer setting for JBoss 7
I suspect that there is no such parameter. I don't find any information about it but how I see it: connector is defined in standolne.xml file in that fragment: <subsystem xmlns="urn:jboss:domain:web:1.1" default-virtual-server="default-host" native="false"> <connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/> <virtual-server name="default-host" enable-welcome-root="true"> <alias name="localhost"/> <alias name="example.com"/> </virtual-server> </subsystem> there is XSD file which describe these part of configuration (it can be found in docs directory): jboss-as-web_1_1.xsd there is no information about socketBuffer parameter in other XSD files I also don't fine such parameter and in jboss-c

Categories : Sockets

Synchronously connecting to a socket in node js
After adding the missing "require" statements and the server.listen() call to get the script to run, it works fine for me: var http = require('http'); var Socket = require('net').Socket; var server = http.createServer(function(req, res){ var sock = new Socket(); sock.connect(80, "www.google.com", function(){ console.log("Connected to google.."); sock.write("GET / "); }); sock.on("data", function(data){ console.log(data.toString()); res.writeHead(404, {"Content-type": "text/plain"}); res.write(data, "binary"); res.end(); sock.end(); }); sock.on("end", function(){ console.log("Disconnected from socket.."); }); }); server.listen(8080);

Categories : Javascript

Connecting C socket server from PHP using PHP Extension
Debug your code properly, could you receive parameters in your C Client code passed from PHP function call, I hope you will not get the parameters which you are passed from PHP function call. Check your parameters receive section, there you have to check the type of values sending from PHP should match the type of declaration in your C Client socket connection scripts. I hope replace your receive parameters section with my following code, it will work. if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ls|b", &i_iPortNumber, &i_pcIPAddress, &return_long) == FAILURE) { RETURN_NULL(); }

Categories : PHP

Connecting Clients machine to MySQL Server machine
You can use other tool with good looking GUI. For example: HeidiSQL. Then, you need to enable remote access. If you use windows, there is nice wizard for you to enable remote access with a few clicks. The wizard is located it at MySQL Server 5.5inMySQLInstanceConfig.exe. Then Reconfigure Instance -> Next -> Standard Configuration -> Next -> Next. You will see this screen. Tick on "Enable root access from remote machines". Or you can manually configure it to allow remote access from my.ini file. See this link for how to do it. If having done above still does not allow you to connect to your MySQL. Please make sure that Firewall does not block MySQL port.

Categories : Mysql

C Socket Append Data To Buffer Gets Corrupted
The problem is these lines: memcpy(raw_response+previousLength, in_buf, retcode); previousLength = retcode; Your function will work for the first and second iterations but after that will start corrupting data. I assume you meant to write previousLength += retcode; There are some other problems with the code which aren't the answer to your question. Firstly, what happens if realloc or malloc fails? You don't check for this in your little sample. Also, you can always just use realloc (which will act like malloc if the pointer is NULL see this SO question). i.e. char *tmp = realloc(raw_response, sizeof(*tmp) * totalLength); if (tmp == NULL) return -ENOMEM; raw_response = tmp; memcpy(raw_response + previousLength, in_buf, ret_code) Secondly, you might call memcpy when ret_code is

Categories : C

PULL socket not connecting fast enough to ROUTER
Why is this happening? You have a race condition. The client1.connect call starts the connection process, but there is no guarantee the actual connection is established when you call rtr.sendMore("client1");. Your sleep() workaround pretty much proves this. Changing PULL to DEALER is a step in the right direction, because DEALER can send and receive. In order to avoid the need for sleeps and waits you would have to change your protocol. A simple change to the code above would be to have the DEALER connect and then immediately send a "HELLO" message to the ROUTER (could be just an empty message). The router code must be redesigned such that it does nothing until it receives a HELLO message from the DEALER. Once you have received the HELLO message you know the connection is succes

Categories : Java

Can a descriptor created by socket() be mapped to a memory buffer?
Is there a way to map a descriptor created by socket() to a memory buffer? No. It doesn't make sense. A mapped file makes sense because of the virtual memory system. A mapped socket doesn't. I want to map a fd returned by the application to a buffer I created. You will have to write code to read from the socket into your buffer.

Categories : Sockets



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