why do we use 10.0.2.2 to connect to local web server instead of using computer ip address in android client

Network Address Space Each instance of the emulator runs behind a virtual router/firewall service that isolates it from your development machine’s network interfaces and settings and from the internet. An emulated device can not see your development machine or other emulator instances on the network. Instead, it sees only that it is connected through Ethernet … Read more

What are the pitfalls of using Websockets in place of RESTful HTTP?

With RESTful HTTP you have a stateless request/response system where the client sends request and server returns the response. With webSockets you have a stateful (or potentially stateful) message passing system where messages can be sent either way and sending a message has a lower overhead than with a RESTful HTTP request/response. The two are … Read more

Java socket API: How to tell if a connection has been closed?

There is no TCP API that will tell you the current state of the connection. isConnected() and isClosed() tell you the current state of your socket. Not the same thing. isConnected() tells you whether you have connected this socket. You have, so it returns true. isClosed() tells you whether you have closed this socket. Until … Read more

Is there a WebSocket client implemented for Python? [closed]

http://pypi.python.org/pypi/websocket-client/ Ridiculously easy to use. sudo pip install websocket-client Sample client code: #!/usr/bin/python from websocket import create_connection ws = create_connection(“ws://localhost:8080/websocket”) print “Sending ‘Hello, World’…” ws.send(“Hello, World”) print “Sent” print “Receiving…” result = ws.recv() print “Received ‘%s'” % result ws.close() Sample server code: #!/usr/bin/python import websocket import thread import time def on_message(ws, message): print message def … Read more

Sending files using POST with HttpURLConnection

I have no idea why the HttpURLConnection class does not provide any means to send files without having to compose the file wrapper manually. Here’s what I ended up doing, but if someone knows a better solution, please let me know. Input data: Bitmap bitmap = myView.getBitmap(); Static stuff: String attachmentName = “bitmap”; String attachmentFileName … Read more

ReactJS server-side rendering vs client-side rendering

For a given website / web-application, you can use react either client-side, server-side or both. Client-Side Over here, you are completely running ReactJS on the browser. This is the simplest setup and includes most examples (including the ones on http://reactjs.org). The initial HTML rendered by the server is a placeholder and the entire UI is … Read more

Client-server synchronization pattern / algorithm?

You should look at how distributed change management works. Look at SVN, CVS and other repositories that manage deltas work. You have several use cases. Synchronize changes. Your change-log (or delta history) approach looks good for this. Clients send their deltas to the server; server consolidates and distributes the deltas to the clients. This is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)