Network Component  Version 7.2
MDK Middleware for IPv4 and IPv6 Networking
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Control Interface

Functions to work with the TFTP server. More...

Functions

netStatus netTFTPs_Start (void)
 Start the TFTP server. [thread-safe].
 
netStatus netTFTPs_Stop (void)
 Stop the TFTP server. [thread-safe].
 
bool netTFTPs_Running (void)
 Check if the TFTP server is running. [thread-safe].
 
uint16_t netTFTPs_GetPort (void)
 Get port number of the TFTP server. [thread-safe].
 
netStatus netTFTPs_SetPort (uint16_t port)
 Set port number of the TFTP server. [thread-safe].
 

Description

Functions to work with the TFTP server.

Like all services, the TFTP server is normally started automatically if NET_START_SERVICE is set to 1 in the Net_Config.c configuration file. If it is disabled, the TFTP server needs to be started manually in the user application using netTFTPs_Start. At runtime, it is always possible to stop the TFTP server using the function netTFTPs_Stop. The user application can check for a running server using the netTFTPs_Running function.

To change the port of the TFTP server at runtime, first call netTFTPs_Stop (if the server is running) and then use the netTFTPs_SetPort function. Afterwards, the TFTP server needs to be (re-)started by the application calling netTFTPs_Start.

Code Example

void change_port (uint16_t port) {}
if (netTFTPs_Running() == true) {
}
}

Function Documentation

uint16_t netTFTPs_GetPort ( void  )

Get port number of the TFTP server. [thread-safe].

Returns
port number.

The function netTFTPs_GetPort returns the port that is used for the TFTP server.

Code Example

printf ("TFTP server is listening on port %d\n", netTFTPs_GetPort ());
bool netTFTPs_Running ( void  )

Check if the TFTP server is running. [thread-safe].

Returns
  • true = Server is running.
  • false = Server is not running.

The function netTFTPs_Running checks whether the TFTP server is running. It returns true if the server is up and running.

Code Example (see netTFTPs_SetPort)

netStatus netTFTPs_SetPort ( uint16_t  port)

Set port number of the TFTP server. [thread-safe].

Parameters
[in]portport number.
Returns
status code that indicates the execution status of the function as defined with netStatus.

The function netTFTPs_SetPort sets the port that is to be used for the TFTP server. The TFTP server must not run while setting the port. If required, stop it first using netTFTPs_Stop.

The argument port specifies the port number to be used.

Code Example

void change_server_port (uint16_t port) {}
if (netTFTPs_Running() == true) {
}
}
netStatus netTFTPs_Start ( void  )

Start the TFTP server. [thread-safe].

Returns
status code that indicates the execution status of the function as defined with netStatus.

The function netTFTPs_Start starts the TFTP server at runtime. It can be stopped again using netTFTPs_Stop.

Note
If you set the NET_START_SERVICE to 1 in Net_Config.c, all selected services will be started automatically. Thus, you only need to call this function, if you have either stopped the TFTP server previously using netTFTPs_Stop or have set NET_START_SERVICE to 0.

Code Example (see netTFTPs_SetPort)

netStatus netTFTPs_Stop ( void  )

Stop the TFTP server. [thread-safe].

Returns
status code that indicates the execution status of the function as defined with netStatus.

The function netTFTPs_Stop stops the TFTP server at runtime. It can be restarted using netTFTPs_Start.

Code Example (see netTFTPs_SetPort)