stop server

Hi all,
We have syntax

server.begin();
client.connect(server,port);
client.stop();

We have client connect and stop syntax. But how can I stop server from further accepting any clients ?
because there is no server.stop() in yunserver class. ?

The simple solution to stop a server from accepting connections is to stop calling the server.accept() function. This doesn't actually stop the server, but in a normal embedded program you wouldn't want to do that. You would normally start things up, and then loop around forever as things happen. Once the server is started, I'm hard pressed to come up with a realistic scenario where you would want to stop it.

A client connection, however, represents a single network socket. There, it certainly does make sense to close the socket (call client.stop()) once you are done with that session.

The code you posted doesn't make sense:

server.begin();
client.connect(server,port);
client.stop();

You don't have any variable declarations, so I'm guessing that server is of type YunServer, and client is of type YunClient.

You use a YunServer to listen for various types of incoming TCP stream connections. By calling server.accept() it either returns a connected YunClient object if there is a pending connection, or a disconnected YunClient if there was no connection pending.

You use a client.connect() call to initiate an outgoing TCP stream connection. There is no server object involved in this case. You have included a server parameter in your client.connect() call, but this is not correct. What connect() is expecting is a string with a server name (URL) in it, or an IP address value.

Hi,
Sorry about that, But firstly just to clarify that code is not complete code at all, just for visual purpose i used code block to mention that specific commands. Yes, its Yunserver and Yunclient. I didn't mentioned all that and not complete code because the question was just needing a way to stop server.
Also

 IPAddress server(192, 168, 1, 177);

takes care of the problem you are mentioning in your last paragraph.
I agree that in realistic, once the server is started we don't need that to stop. But won't it be natural if we do need to stop, there should be a way or command right? ( of course other way then switching off the power supply)

swaroop2011:
But won't it be natural if we do need to stop, there should be a way or command right? ( of course other way then switching off the power supply)

I suppose it would make sense to have it for completeness, but I still don't see a realistic use case for it. Turning off the power supply IS the customary way to stop an embedded project.

Just after posting my reply, I saw your other thread about stopping the Linux server, and that gives a little more insight to what you're trying to accomplish. But again, in that scenario, loading a new sketch, while it frequently occurs in a development scenario, is also not a common use case once the embedded system is deployed. In that thread, it was also clear that the "server" in the client.connect() call above was actually an IP address object. So yes, with that extra information, it is true that much of what I wrote in the latter part of the post above is a moot point.