|
"peter " <petermuellers@online.de> wrote in message
news:ired0u$evf$1@newscl01ah.mathworks.com...
>> Hi Peter,
>>
>> The syntax is possible. Depending upon your requirements, you may
>> discover that opening will happen sequentially underneath.
>>
>> obj1 = tcpip('localhost', 7);
>> obj2 = tcpip('localhost', 7);
>> ports = [obj1,obj2];
>> echotcpip('on',7);
>> fopen(ports);
>> ...
>> fclose(ports);
>> echotcpip('off');
>>
>
> Thanks for your response.
> I am not sure if I get the point. So you are able to open as much
> connections as you want, but there is just one (the last opened one) that
> is active? How can I change between different connections? I am not sure
> about using the fopen command a second time.
> Is there any possibiility to store data sent by the other (inactive)
> connections?
> For example:
>
> obj1 = tcpip('192.168.0.2', 7);
> obj2 = tcpip('192.168.0.3',7); fopen(obj1);
> fopen(obj2);
> ...
> now I want to receive/sent data from/to obj1 and obj2 simultaneously ...
> fclose(obj1);
> fclose(obj2);
>
> thanks again :)
>
Hi Peter,
I think I read too much into 'simultaneously' when I gave an example of
opening both ports in one FOPEN.
You can have multiple TCPIP objects in your workspace. Each object may be
opened and closed at any time. The example just showed opening both objects
at the 'same time' in one line of code. In your example, you will need two
remote machines with IP addresses 192.168.0.2 and 192.168.0.3 but it should
work. The example I gave just uses the echoserver on the local host for
testing. Perhaps the following example will help you understand what is
possible:
>> obj1 = tcpip('localhost', 7);
>> obj2 = tcpip('localhost', 7);
>> echotcpip('on',7);
>> fopen(obj1); fopen(obj2);
>> fprintf(obj1,'test1')
>> fprintf(obj2,'test2')
>> fscanf(obj2)
ans =
test2
>> fscanf(obj1)
ans =
test1
>> fclose(obj1);
>> fclose(obj2);
You can try closing the objects and reopening them in various combinations.
The above example shows that you can have two objects open and they are
independant of each other.
|