Port and Host Configuration of SmartFoxServer2X


SmartfoxServer2x is an event based Client-Server Communication server. In order to establish a connection between the Server and Client these things will happen in any server (even in smartfoxserver2x also).

  1. The Server Will Listens the clients requests from a port by opening it (A Port is a virtualisation identifier defining a service endpoint). By default the SmartfoxServer2x will listen client connections at port 9933.
  2. Client will sends the request by connecting to server by opening a connection to the above opened server port.
  3. Based on the request server will process the request and returns the response to client.

Key things to know are



Where the server port is configured in SmartfoxServer2x?

top
  1. SmartfoxServer2x consists a file named server.xml in the path Smartfox2x -> SFS2X-> Config-> server.xml.
  2. In that server.xml file a <socket> tag will hold’s port attribute there we need to modify. By default it will in the manner
<socket address="0.0.0.0" port="9933" type="TCP"/>
Attribute Description
address Refers the host/ip of server machine.
port SmartfoxServer2x will accept client connections to the specified port
type Protocol of communication allowed values or either TCP or UDP

How to alter the server port as our need (custom port settings)?

top
  1. Open the server.xml file (using the above steps) and assign custom port number to the port attribute in <socket> tags.
  2. Open the firewall to open the ports for accepting remote connections.
  3. Restart the Server after saving the server.xml file.

Suppose I want to start the server in the port 2016 the steps are

  • In server.xml
<socket address="0.0.0.0" port="2016" type="TCP"/>
<socket address="0.0.0.0" port="2016" type="UDP"/>
  • Opening firewall inbound and outbound rules based on Operating System.(Check this link for opening firewall)
  • Restarting the server.
  • 4. If the specified port (2016) is already in use (if any other programing is using the same port then) we will get PortBoundException from server like ‘port xxxx’ is already in use. Then mention the other port


How to configure our Host/IP address to SmartfoxServer2x?

top
  1. By default SmartfoxServer2x is configured to run and accept the connections from/in local network, if we want to start and bind the SmartfoxServer2x to any particular IP/Host then we need the alter the “address” attribute of <socket> tags in server.xml.

Example: -

I want to bind the SmartfoxServer2x connections, to the machine named "smartfox.tutorialtous.com" or its equvaling IP "X.Y.P.Q"

then the <socket> tags are as follows.

  • In server.xml
<socket address="127.0.0.1" port="2016" type="TCP"/>
 <socket address="127.0.0.1" port="2016" type="UDP"/>

<socket address="smartfox.tutorialtous.com" port="2016" type="TCP"/>  
<socket address="smartfox.tutorialtous.com" port="2016" type="UDP"/>  

<socket address="X.Y.P.Q" port="2016" type="TCP"/>  
<socket address="X.Y.P.Q" port="2016" type="UDP"/>
  • Opening firewall inbound and outbound rules based on Operating System.(Check this link for opening firewall)
  • Restarting the server.
  • 4. If the specified port (2016) is already in use (if any other programing is using the same port then) we will get PortBoundException from server like ‘port xxxx’ is already in use. Then mention the other port
Copyright © 2018-2020 TutorialToUs. All rights reserved.