Sources are places where the Flink program expects to get its data from. This is a second step in the Flink program's anatomy. Flink supports a number of pre-implemented data source functions. It also supports writing custom data source functions so anything that is not supported can be programmed easily. First let's try to understand the built-in source functions.
DataStream API supports reading data from a socket. You just need to specify the host and port to read the data from and it will do the work:
socketTextStream(hostName, port);
You can also choose to specify the delimiter:
socketTextStream(hostName,port,delimiter)
You can also specify the maximum number of times the API should try to fetch the data:
socketTextStream(hostName,port,delimiter, maxRetry)