T - The type of elements returned from the iterator.@Experimental public class SocketStreamIterator<T> extends Object implements Iterator<T>
The iterator's constructor opens a server socket. In the first call to next() or
hasNext(), the iterator waits for a socket to connect, and starts receiving,
deserializing, and returning the data from that socket.
This experimental class is relocated from flink-streaming-contrib. Please see package-info.java for more information.
| Constructor and Description |
|---|
SocketStreamIterator(int port,
InetAddress address,
org.apache.flink.api.common.typeutils.TypeSerializer<T> serializer)
Creates an iterator that returns the data from a socket stream with custom port and bind
address.
|
SocketStreamIterator(org.apache.flink.api.common.typeutils.TypeSerializer<T> serializer)
Creates an iterator that returns the data from a socket stream with automatic port and bind
address.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
InetAddress |
getBindAddress() |
int |
getPort()
Returns the port on which the iterator is getting the data.
|
boolean |
hasNext()
Returns true if the DataStream has more elements.
|
T |
next()
Returns the next element of the DataStream.
|
void |
notifyOfError(Throwable error) |
void |
remove() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitforEachRemainingpublic SocketStreamIterator(org.apache.flink.api.common.typeutils.TypeSerializer<T> serializer) throws IOException
serializer - serializer used for deserializing incoming recordsIOException - thrown if socket cannot be openedpublic SocketStreamIterator(int port,
InetAddress address,
org.apache.flink.api.common.typeutils.TypeSerializer<T> serializer)
throws IOException
port - port for the socket connection (0 means automatic port selection)address - address for the socket connectionserializer - serializer used for deserializing incoming recordsIOException - thrown if socket cannot be openedpublic int getPort()
public InetAddress getBindAddress()
public void close()
public boolean hasNext()
public T next()
next in interface Iterator<T>NoSuchElementException - if the stream has already endedpublic void notifyOfError(Throwable error)
Copyright © 2014–2025 The Apache Software Foundation. All rights reserved.