Q:

Web-service and Socket Programming - Locally which is faster

I've create an android - desktop socket programming for transferring data. The socket communication is duplex based, in which client is on android and server is on desktop. At one time there may be so many android clients be connected to the desktop server.The application is working fine in some extends, some problem which i felt is connection breakage since I'm using WiFi, slow when bulk data need to transfer.
Recently i learned about REST web-services, and I've created an application in which a web-service runs on a desktop machine locally and android application connects to it via HTTP POST and HTTP GET, and transfer data from either sides as good.
I would like to know whether Socket programming is better or webservice is better for communication and bulk data exchange locally? which one is faster? 
Can anyone please tell me some solution for this?

A:

Sockets are faster than web services in general.

As you master both sides of the communication you can have your own data format, which can be much more efficient than what you're allowed to do with http
Depending on what you're sending, you may have a very simple message structure, whereas http will always require its header for example, which adds data to transfer
Classic http is opening and closing the communication channel for each request, which is quite inefficient

However, on this last point as you're on a slow, unstable wifi connection it is not bad to reconnect for each request.
I would recommend you to have a look to zmq, it is a library for message queues between applications with a great variety of supported topologies. There are bindings for a lot of languages, and it also works on Android. You may find it better than plain sockets + your own message protocol, or http.

