简体   繁体   中英

server socket is the best option to perform

I am doubtful on what to use to do this:

I wanted to have a .bat file (which would be open on a machine and through that bat I would be able to have event logs from my application / and would run routines through it like "save a backup"). And my login system would only work if this .bat file is open something like a "GAMESERVER" (I do not know if this is necessary, but I wanted to do it for training)

I had thought of creating an auxilary table in the database with only 2 fields id / a boolean field.

When you open this. bat would make connection and set that value to 1

and in my login system I would check if this value is 1, and then I could free the login.

I do not know if this is the best way

Or in that case would it be better to use a serversocket?

Could someone give me an example of how I can get started?

For what you want you don't need a server socket. I posted that link so you can understand what it is. Logging events into a file, you just need the basic understanding of reading/writing into a file. The .bat extension doesn't matter. But if you want your .bat to be executed from command line as batch commands, then the file will need to be a valid batch script.

The question you'll have to ask yourself is: "Who's gonna connect to your server? How?" Then only you can determine what you really need.

Server Sockets are used for live communications:

Normally, a server runs on a specific computer and has a socket that is bound to a specific port number. The server just waits, listening to the socket for a client to make a connection request.

On the client-side: The client knows the hostname of the machine on which the server is running and the port number on which the server is listening. To make a connection request, the client tries to rendezvous with the server on the server's machine and port. The client also needs to identify itself to the server so it binds to a local port number that it will use during this connection. This is usually assigned by the system.

This comes from : https://docs.oracle.com/javase/tutorial/networking/sockets/definition.html

Changing a value from 0 to 1 if connected and from 1 to 0 if not, that's just like saving a preference into a file. and all you need to know for that is how to manipulate files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM