If you need the udp function in your start function, you can also create it in the start function and pass it to the original call as a parameter. Thus, you do not need to call the server after it is created.
rvirding indicates that this will cause the initial process to receive messages from the udp socket, rather than from the newly created server. See Comments for more information. It is not clear what exactly is needed for the socket in the start method, but make sure that this is what you want.
start() -> {ok, Socket} = gen_udp:open(8888, [list, {active,false}]), {ok, ServerPid} = gen_server:start_link(?MODULE, Socket, []). %%% gen_server API init(Socket) -> {ok, Socket}.
source share