Ep. 16: Server Packet Receiving – Network Chat Programming




Github commit for this episode:

————————————————————————————————-

In this video:
– How to start a server
– How to listen for data
– How to receive data as a server
– How to create a server

————————————————————————————————-

Website:
Twitter:
Facebook:
Subreddit:
Steam Group:

————————————————————————————————-

Outro music is by Approaching Nirvana:

source

46 thoughts on “Ep. 16: Server Packet Receiving – Network Chat Programming”

  1. Btw, can anyone help me? xD I get an exception when i try to connect :/
    *
    Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    *

  2. Haha okay i gone to the github and found the problem :$ sorry ๐Ÿ˜€ didnt write it down perfectly apperently…

  3. Hey Cherno, I am considering going into app dev. for the android. I have experience in c, c++, java, and python. I was wondering if you would consider doing a tutorial on app dev. in the near future. I think your audience would be interested in it.

  4. Hey cherno I know you don't like this but I have idea for Game Programming. The idea is that we draw map inside of game rather than drawing it in 3rd party sofware.

    I hope you can make it ๐Ÿ˜€

  5. I still think UDP is actually unreliable because it may crash your network if the server just forces it self to shutdown and the UDP packets have nowhere to go and just flood your network

  6. You should show us how to export the files into runnable and regular jar files. I watched your 3D tutorials where you export to an runnable jar file. But it doesn't really work with the server etc.

  7. Come on guys, there are 600 views, we can give him more like, I mean you do like, right? it helps him, inspires him to do more, and gives us more content to watch ๐Ÿ™‚

  8. I've checked line by line now, and yet when i enter a message in the client, it doesn't show up for the server, I would very much appreciate if someone were to explain what I've done wrong.

  9. I don't think that's the case, because in Eclipse the program runs fine without errors or anything, but when I export it this error occurs.

  10. You may not have Java set up properly. Try running cmd and type java and see what happens, if it is working you should get a list of options.

  11. Java is set up properly. I do get a list of options and I usually play Minecraft and code other things in Java, so yes it is set up properly. This is not the case :/

  12. I have a problem in the Server Console, after every messaje, it shows a lot of garbage, whats going on? ๐Ÿ™

  13. For some reason, depending on the size of the byte array, the console prints out a ton of spaces after it receives a message. If i change the byte size form 1024 to something like 512 the spaces reduces by half. So it's connected to the byte[] length… but i don't know why it's only doing it to me.

  14. Figured it out. instead of String string = new String(packet.getData()); I had to change it to String string = new String(packet.getData(), 0, packet.getLength(), "UTF-8"); Because for some reason, i need the packets to be 8 bit to send correctly. I believe this fixes Calos Martinez' Problem.

  15. I'm having a problem where in the console after I type a message it shows the message and then it shows a bunch of question marks in boxes. Please help ๐Ÿ™

  16. I have done it like you said but the only thing i get to see in my console is Usage: java -jar ChernoChatServer.jar [port]

    how do i fix this?

  17. I didnt get the error!!! ย Im assuming that means Im not opening the socket and in fact when I send I dont recieve nothing in the sever side!! ย  But doesnt look wrong :/ and the server is not recieveng anything :/

  18. I still don't understand why do you need a separate thread for sending messages from the client? The socket.send() method executes instantly, unlike socket.receive(). And you don't even need a thread for that either, since the GUI already runs on its own separate thread and the application won't freeze. Using threads in the client app would only make sense when connecting to multiple servers.

  19. In receiveClients method in Server what exactly happens when you call socket.recieve(packet);?
    I heard him say the server socket will then wait for a packet but what I'm trying to understand is
    does the while loop start waiting the first or the second time around that it crosses the socket.recieve(packet); step and why??.

    I'm a noob and I have a bit of trouble with this recursive stuff (if this is recursion). Plz help

  20. hey bro! From this tutorial I was trying to do something like u but problem is my manage thread and receive thread doesn't running. What should I do for this problem? Please give me solution.

  21. it is good to at least explain it like this, so I am not confused as to why is it done that way…

Leave a Reply