I read through your profile and saw you are a 17 year old developer hobbiest. I didn't know what OO was at that age. Well done. I made this review under the impression you were a somewhat experienced professional.
The constructor silently catches IOException. This leaves the socket in a corrupted state. Throw any exception up the ...
I also did not get to the Client. Here are some observations:
Don't use tombstone comments at the top of a class. Use proper JavaDoc which details the expected use of the class.
Star imports are discouraged. It's preferable to specify what classes you're importing in most cases.
Curly braces should be used even when they're optional. It's arguably pretty ...
This looks very reasonable, but some improvements are possible:
getsockname() returns the local side's address
In your code you write:
client_sock, client_addr = sock.accept()
print('Connection from', client_sock.getsockname())
That should have been client_sock.getpeername(). But you don't need to call any extra function, since the address of the ...
Nothing looks too bad, but there's some things you can improve when it comes to readability and other Java-specific stuff.
// Multithreaded server program
public class BullsAndCowsServer
public static void main(String args) throws ...
You have 2 requirements stated below. I see no reason why to re-invent-the-wheel here. Both requirements can be met with using common practices.
..or a mechanism to drop packages rather fast
before reading all the package content. (In case somebody sends an
array with 10k elements, continuously to make denial of service).
This should ...
The methods DecodeInt32 and DecodeInt16 are very confusing. The bitwise or (|) of 2 bytes can never give you something less than 0. Furthermore, bytes << 24 can give you a negative number. I really have no idea what these methods are meant to achieve.
Also, your packetId seems to be included in the packetLength, which may create issues in the ...
You need to use some kind wire protocol. In simplest case a triple (int length, int/enum
for tag/type, byte data). Then you will be able to differentiate between command "ping" and a sending a file with content "ping". Also look into ProtoBuf or ObjectInputStream - it is futile to try parsing objects from toString() output.