tcpserverfind
Description
finds servers with property values matching those specified by one or more name-value
arguments. For instance, T = tcpserverfind(Name=Value)T = tcpserverfind(Tag="Scope") returns existing
servers whose Tag property is set to "Scope".
Examples
When you have a tcpserver connection that exists in
the MATLAB® workspace or is saved as a class property or app property, the
tcpserver object might not be accessible in a different function or
app callback. In this case, you can use tcpserverfind to find and
delete the connection.
T = tcpserverfind
T =
TCPServer with properties:
ServerAddress: "127.0.0.1"
ServerPort: 6000
Connected: 0
ClientAddress: ""
ClientPort: []
Tag: "Analyzer"
NumBytesAvailable: 0
To close this connection, delete T.
delete(T)
This command deletes the tcpserver object and disconnects the
server. If you want to reconnect to the server, you must create a new server
interface with tcpserver.
After the deletion, calling tcpserverfind confirms that there
are no existing connections.
tcpserverfind
ans =
[]Note that the variable T is still present in the workspace, but
it is now an invalid handle.
T
T = handle to deleted tcpserver
The variable persists after deletion of the interface because
tcpserver is a handle object. (For more
information about this type of object, see Handle Object Behavior.) You can use clear to remove the invalid handle from the
workspace.
clear TYou can assign a tag to a TCP/IP server and use that tag with
tcpserverfind to access the server later. Such tags are useful when
you have multiple servers to keep track of across several functions. Tags are also useful
for locating and accessing servers in app callbacks. To set the tag value, use the
Tag property of tcpcserver.
Create two TCP/IP servers, assigning values to the Tag
property.
s1 = tcpserver("localhost",4000,Tag="Scope"); s2 = tcpserver("localhost",6000,Tag="Analyzer");
Find the server with the tag "Analyzer".
T = tcpserverfind(Tag="Analyzer")T =
TCPServer with properties:
ServerAddress: "127.0.0.1"
ServerPort: 6000
Connected: 0
ClientAddress: ""
ClientPort: []
Tag: "Analyzer"
NumBytesAvailable: 0
Show all properties, functionsName-Value Arguments
Specify optional pairs of arguments as
Name1=Value1,...,NameN=ValueN, where Name is
the argument name and Value is the corresponding value.
Name-value arguments must appear after other arguments, but the order of the
pairs does not matter.
Example: tcpserverfind(Tag="Scope",ServerPort=6000) returns existing
servers using port 6000 whose Tag property is set to
"Scope".
For tcpserverfind, you can use one or more properties of the
tcpserver
object as name-value arguments to specify characteristics of the servers you want to
find.
Output Arguments
TCP/IP servers, returned as a tcpserver object or an array of
tcpserver objects. If you call tcpserverfind
with no name-value arguments, T contains all existing TCP/IP
servers. Otherwise, T contains all servers whose properties match
the values you specify with name-value arguments.
T is empty if:
There are no existing TCP/IP servers.
No existing servers match the specified property values. For instance, if you specify
Tag="Scope"and there is no existing server whoseTagproperty is"Scope", thenTis empty.You try to match a property that the
tcpserverobject does not have. For instance,tcpserverfind(Speed=14400)returns an empty array becausetcpserverdoes not have aSpeedproperty.
Version History
Introduced in R2024a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Website auswählen
Wählen Sie eine Website aus, um übersetzte Inhalte (sofern verfügbar) sowie lokale Veranstaltungen und Angebote anzuzeigen. Auf der Grundlage Ihres Standorts empfehlen wir Ihnen die folgende Auswahl: .
Sie können auch eine Website aus der folgenden Liste auswählen:
So erhalten Sie die bestmögliche Leistung auf der Website
Wählen Sie für die bestmögliche Website-Leistung die Website für China (auf Chinesisch oder Englisch). Andere landesspezifische Websites von MathWorks sind für Besuche von Ihrem Standort aus nicht optimiert.
Amerika
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)