serversocket

How would an MMO deal with calculating and sending packets for thousands of players every tick for a live action game?

ぃ、小莉子 提交于 2019-12-20 05:43:10
问题 I am working on a game and I am thinking about getting into networking. I have been programming for about 5 years and got into game development the last 2 years. I only really learn online and from books on my own time. I am planning to make a java server for Amazon AWS EC2, but I am just wondering how MMO's handle multiple players each tick. Is it just the sheer power of servers? I am not looking for code or anything, just in general how the servers work. Does the server just do all of the

Usage of getaddrinfo() with AI_PASSIVE

只谈情不闲聊 提交于 2019-12-19 07:24:49
问题 The getaddrinfo() function not only allows for client programs to efficiently find the correct data for creating a socket to a given host, it also allows for servers to bind to the correct socket - in theory. I just learned about that and started to play around with it via Python: from socket import * for i in getaddrinfo(None, 22, AF_UNSPEC, SOCK_STREAM, IPPROTO_IP, AI_PASSIVE): i yields (2, 1, 6, '', ('0.0.0.0', 22)) (10, 1, 6, '', ('::', 22, 0, 0)) what makes me wonder about if there is

Usage of getaddrinfo() with AI_PASSIVE

白昼怎懂夜的黑 提交于 2019-12-19 07:24:32
问题 The getaddrinfo() function not only allows for client programs to efficiently find the correct data for creating a socket to a given host, it also allows for servers to bind to the correct socket - in theory. I just learned about that and started to play around with it via Python: from socket import * for i in getaddrinfo(None, 22, AF_UNSPEC, SOCK_STREAM, IPPROTO_IP, AI_PASSIVE): i yields (2, 1, 6, '', ('0.0.0.0', 22)) (10, 1, 6, '', ('::', 22, 0, 0)) what makes me wonder about if there is

How does serversocket class serve multiple client connections on same port?

自古美人都是妖i 提交于 2019-12-18 19:06:52
问题 When using a Socket class one is establishing a TCP connection to a server on some port, but on the server the ServerSocket is capable of handling multiple client connections for each accept request and delegate it to a thread to server the request. But how is it possible for a ServerSocket class to accept multiple tcp connections on the same port. Does it mean that it is upto the OS to decide how many connections it allows or what is the maximum backlog allowed and can this be controlled by

How to make GUI Client to upload file in java

社会主义新天地 提交于 2019-12-18 09:25:41
问题 Please help me I want to make a GUI application which upload a file from client to server. when I click on browse button then file is copy in bytes form because we travel data in bytes on network but when I click on upload button then file cannot upload. import javax.swing.*; import java.awt.event.*; import java.io.*; import java.net.*; class ClientUpload extends JFrame implements ActionListener { JFileChooser fc; JButton b, b1; JTextField tf; FileInputStream in; Socket s; DataOutputStream

how do i connect to the server socket using the ip address and port number( client is running on a different machine than server)

若如初见. 提交于 2019-12-18 04:23:36
问题 Client program public class client implements Runnable { protected static String server_IP = "141.117.57.42"; private static final int server_Port = 5555 ; protected static String client_IP ; public static void main(String[] args) throws IOException{ final String host = "localhost"; int init = 0 ; try { InetAddress iAddress = InetAddress.getLocalHost(); client_IP = iAddress.getHostAddress(); System.out.println("Current IP address : " +client_IP); } catch (UnknownHostException e) { } try

Proper way to close an AutoCloseable

巧了我就是萌 提交于 2019-12-17 02:32:14
问题 What is the most reliable pattern to follow when closing an OutputStream, ServerSocket, or other object that implements the AutoCloseable interface? Should I use try - catch - finally ? Or a shutdown hook. 回答1: The correct way to use an AutoCloseable instance is with a try-with-resources block, so the resource is reliably closed even if an exception is thrown. Like this: try (OutputStream stream = new ...) { ... // use the resource } catch (IOException e) { ... // exception handling code }

Java: How can I create an application that will only start if an instance of it doesn't exist and call the instance if it does exist?

☆樱花仙子☆ 提交于 2019-12-14 03:58:07
问题 I am trying to create a program with Java that can only have one instance of it running at a time. I am using Sockets and ServerSockets to try to achieve this. How the program is supposed to work is: The main method will check if any parameters have been passed, it will try to write the first parameter to the server, if it fails that means, that means that this is the only running instance, so it will open the ServerSocket and then start the frame. If it doesn't fail then the application is

Writing to an AsynchronousSocketChannel and processing the data in an Event-based way

喜欢而已 提交于 2019-12-13 21:08:20
问题 I'm trying to figure out how to send data between sockets in Java (this is part of a bigger project and I'll get back and answer my previous two questions related to that once I can resolve this..). I would like to connect a client and a server socket asynchronously in Java, and then send messages between them, and get a callback, say, when I have sent a message from the client to the server. I think I have managed to get the set-up working. Here is my code: private

Use Socket-communication over different networks

℡╲_俬逩灬. 提交于 2019-12-13 17:25:08
问题 Hello fellow stackoverflowers! I'm currently developing this app that should be able to communicate device-to-device. I found this cool guide on how to use Socket for that kind of communication. And it worked! ..ish. My problem is that it only works while the two devices is connected to the same Wi-Fi. Which sucks... So if device-A is the server & device-B is the client, and I use the internal-IP address (like, 192.168.1.blahblahbla), it works. -That's awesome, then why're complaining bro?