Questions tagged [client-server]

DO NOT USE ALONE. The client-server model is a centralized model, in which a server performs a specialized service (such as HTTP, SMTP, etc.) for multiple clients on request. Use for issues regarding client server communication. Use with a appropriate language tag(eg: [python]).

The client-server centralized model is a model in which servers perform services for many clients, who request them, typically over a network. The client-server model contrasts with the peer-to-peer model.

Typically, a client-server interaction will work as such:

  1. The client connects to the server and issues a request. The request is formatted to any one of a number of protocols, depending on the server type.
  2. The server receives the request, and begins processing it. While this happens, the client is made to wait.
  3. The server sends the client a response which typically contains both a status (whether or not there was an error) and content (which is whatever the client asked for originally).
  4. The client or the server can either terminate the connection, or keep it alive for further requests.

Writing in a client-server domain presents a number of challenges:

  • Many, many clients may be requesting services at any given time. This issue is commonly faced by websites, and is typically solved with multiple layers of load-balancing and caching. Wikipedia's architecture is an example of this (albeit an unusually complex example).
  • Networks can easily become unreliable, and sessions can be terminated at any time.
  • Security can be an issue, due to security compromises like a Man In The Middle attack. Cryptography algorithms (like SSL) are widely deployed in various networking areas to combat this.
6508 questions
458
votes
5 answers

How do multiple clients connect simultaneously to one port, say 80, on a server?

I understand the basics of how ports work. However, what I don't get is how multiple clients can simultaneously connect to say port 80. I know each client has a unique (for their machine) port. Does the server reply back from an available port to…
IamIC
  • 17,747
  • 20
  • 91
  • 154
315
votes
17 answers

Sending POST data in Android

I'm experienced with PHP, JavaScript and a lot of other scripting languages, but I don't have a lot of experience with Java or Android. I'm looking for a way to send POST data to a PHP script and display the result.
OMGKurtNilsen
  • 5,048
  • 7
  • 27
  • 36
251
votes
7 answers

Client-server synchronization pattern / algorithm?

I have a feeling that there must be client-server synchronization patterns out there. But i totally failed to google up one. Situation is quite simple - server is the central node, that multiple clients connect to and manipulate same data. Data can…
tm_lv
  • 6,442
  • 5
  • 24
  • 16
161
votes
4 answers

ReactJS server-side rendering vs client-side rendering

I just have began to study ReactJS and found that it gives you 2 ways to render pages: server-side and client-side. But, I can't understand how to use it together. Is it 2 separate ways to build the application, or can they be used together? If we…
Simcha
  • 3,300
  • 7
  • 29
  • 42
129
votes
8 answers

Sending files using POST with HttpURLConnection

Since the Android developers recommend to use the HttpURLConnection class, I was wondering if anyone can provide me with a good example on how to send a bitmap "file" (actually an in-memory stream) via POST to an Apache HTTP server. I'm not…
Mihai Todor
  • 8,014
  • 9
  • 49
  • 86
118
votes
5 answers

Is there a WebSocket client implemented for Python?

I found this project: http://code.google.com/p/standalonewebsocketserver/ for a WebSocket server, but I need to implement a WebSocket client in python, more exactly I need to receive some commands from XMPP in my WebSocket server.
diegueus9
  • 29,351
  • 16
  • 62
  • 74
116
votes
9 answers

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

I am running into some issues with the Java socket API. I am trying to display the number of players currently connected to my game. It is easy to determine when a player has connected. However, it seems unnecessarily difficult to determine when a…
Dan Brouwer
  • 1,161
  • 2
  • 9
  • 3
115
votes
9 answers

How to convert from []byte to int in Go Programming

I need to create a client-server example over TCP. In the client side I read 2 numbers and I send them to the server. The problem I faced is that I can't convert from []byte to int, because the communication accept only data of type []byte. Is there…
Emanuel
  • 6,622
  • 20
  • 58
  • 78
96
votes
3 answers

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

I am currently working on a project that requires the client requesting a big job and sending it to the server. Then the server divides up the job and responds with an array of urls for the client to make a GET call on and stream back the data. I am…
smuggledPancakes
  • 9,881
  • 20
  • 74
  • 113
96
votes
2 answers

How to store data in S3 and allow user access in a secure way with rails API / iOS client?

I am new to writing Rails and APIs. I need some help with S3 storage solution. Here's my problem. I am writing an API for an iOS app where the users login with the Facebook API on iOS. The server validates the user against the token Facebook issues…
dineth
  • 9,822
  • 6
  • 32
  • 39
89
votes
6 answers

Synchronizing client-server databases

I'm looking for some general strategies for synchronizing data on a central server with client applications that are not always online. In my particular case, I have an android phone application with an sqlite database and a PHP web application with…
82
votes
4 answers

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

We normally use 10.0.2.2:(port number) in the url to connect to the local web server,but we should use the computer's ip address instead of 10.0.2.2 Then why do we use 10.0.2.2?
Touchstone
  • 5,575
  • 7
  • 41
  • 48
63
votes
10 answers

java.io.InvalidClassException: local class incompatible:

I created client and server and then added a class in client side for serializing purposes, then simply just went to the folder of the client in my hard drive and copy paste it to the server correponding location, both classname.class and…
lonesome
  • 2,503
  • 6
  • 35
  • 61
61
votes
3 answers

Does TCP send a SYN/ACK on every packet or only on the first connection?

I have a TCP server that listens for an incoming client, then sends it one packet of data every second. I was wondering, does the SYN/ACK packet only get sent on initial connection, so it looks like this:
Daniel T.
  • 37,212
  • 36
  • 139
  • 206
52
votes
3 answers

Does the port change when a server accepts a TCP connection?

When a client connects to a server using TCP, a new socket is created for the TCP stream. Does the connection remain on the same port the connection was made or does it get changed to some other port?
zooropa
  • 3,929
  • 8
  • 39
  • 61
1
2 3
99 100