This content has been marked as final. Show 10 replies
please someone help. I finally got sockets down, but how do i insert them into sites for access and how can i make a thread make it available to more then one person.
help yourself. Learning quickly is NOT a good thing, a good developer takes the time to study and research. Understand what you are doing.
For example, do you know about latency? Keeping clients synchronized by making your game updates and movements based on a clock pulse? Interpolation between frames to smooth out lag hiccups?
Those are topics you wouldn't learn if you would go fast fast fast and only study Java sockets.
I just want to know how to send images over the socket. And how to send key information back. I know how to make a socket but how would i send data back to it. Also how can someone access mine from their computer if i have wireless. Thats all i need to know now.
Dude, the questions you make doesn't seem that you understand at all game architecture.. It took me 4 years(of studing and making work in univercity) to start making something that I can show to others in year or two.. Start doidn simple stuff, make a little chat, this will at list get you more familiar with sockets and how they work.. There are a lot of tutorials about networking.. No1 will tell you step by step of the basics..
What i am asking, is how to send stuff other then words over a server and how to send it to multiple clients. My chat will let me send th data to the server but not back to both clients
Your question makes no sense whatsoever. The socket doesn't know what's being sent over it, so sending text or binary data works in exactly the same way (text IS binary data after all to the computer, it's only to the human that there's any distinction whatsoever).
I hope this is correct, since I don't have very much experience with working over network stuff.
It is true that you can only really send stuff over sockets is binary (and preset classes that allow strings, integers, doubles, etc.), so in order to send a picture, you need the sender to convert the picture into a format that fits one of these categories. For example, BufferedImage has a method that will convert the BufferedImage into a Raster, and Raster can convert into an int, float, or double array representing the samples.
The receiver will have to be able to take this data and convert it back into a Raster, then back to a BufferedImage (or whatever class you are using). Raster has several static classes on which to create a Raster, but I'm not sure on how to use them, since I haven't ever used them myself.
There's probably a better method of going about this, but this is just a thought. Sorry for not being more helpful.
Abion47 wrote:Well, yes and no. It's "only binary" in exactly the same way that files are "only binary." But the various applications can apply interpretations to the bytes. For instance, when using FTP, you can set it to "text" or "ascii" mode, which means the ftp server (or maybe it's the client) will translate line-end characters as needed to map from the sending platform's conventions to the receiver's.
It is true that you can only really send stuff over sockets is binary
in order to send a picture, you need the sender to convert the picture into a format that fits one of these categories.Not sure what you're saying here, but the format of the payload is irrelevant to the network communication part, as long as the protocol supports sending the bytes in question. The format of the data comes into play before sending and after receiving. It's here that the sender and receiver must be in agreement in order for the payload to be properly interpreted.
I think the OP meant to indicate that he wishes to use graphics in his game.
In that case, just put the images on the server. It's as simple as that. In an applet you can do something like g.drawImage (imageName) and the image named imageName can simply be on the server. Java will download it automatically and put it in the game. When you want to send things between players, it's a little harder. You'll need to do things like send position variables to the server and receive information about other players' positions from the server using a Socket.
To reduce lag, you may want to look into the DatagramSocket class for your game. Basically, you'll need to periodically send packets to the server updating the server on the position, etc. of your character. The server will need to broadcast such data to all connected players.
cannon701 wrote:An applet runs in the client (your machine.) Normally to run with others you are going to need an actual server. So the first question would be if your hosting service allows you to run a server application.
Hey, I am having trouble with sockets. I am wanting to make a game that is multiplayer and will work on a freewebs site. It probably needs to use applet or JApplet(for guis).
I want it to work with everyone on the server, but i think it would be easier to just use a tcp and let others join in by using ip address. The problem is, I am not really good with Sockets and barely know stuff about them. I also want to make a game with images and stuff like that but all i can do is g.drawoval(). I get guis mighty fine they are easy. I want the game to be like mario but you can have friends play with you using your ip.
If it does then an easy start is to add a highest score list. Those that play your game on there computer can add their score to the list (on the server) and see who else scored there.