I'm not entirely sure if I compacted this well enough, but after class declaration and method calling, it is essentially what my program does.
Server server = new Server(); // Creates a ServerSocket and binds it to a port.
Client client = new Client(server.getSocketAddress());
public Client(SocketAddress bind)
{
try
{
socket = new Socket();
socket.bind(bind); // Problem here
recieve = new Scanner(socket.getInputStream());
send = new Formatter(socket.getOutputStream());
}
catch (IOException e)
{
e.printStackTrace();
}
}
Running the above code produces the following exception.
java.net.SocketException: Unrecognized Windows Sockets error: 0: JVM_Bind
at java.net.PlainSocketImpl.socketBind(Native Method)
at java.net.PlainSocketImpl.bind(Unknown Source)
at java.net.Socket.bind(Unknown Source)
at GameObjects.PlayArea$Client.<init>(PlayArea.java:318)
at GameObjects.PlayArea.<init>(PlayArea.java:48)
at MenuStates.GamePlayState.initializePlayArea(GamePlayState.java:90)
at MenuStates.CreateGameState.mouseClicked(CreateGameState.java:106)
at Manager.GameManager.mouseClicked(GameManager.java:428)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Window.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
I don't even know what this exception is, and I can't find anything that will really tell me what is going on. Can anyone tell me what is happening here?
I know that this question isn't directly related to Game Development, but I am using it in a game program, and I posted this question in the Network forum, and they flooded my topic with useless messages, and the only person who actually answered my question was extremely vague about it, even after I asked him to clarify. I am hoping that the good people of this forum will be more helpful.