TCP/IP connection to .NET

For questions and postings not covered by the other forums
User avatar
rudzitis
Posts: 8
Joined: Tue Jan 11, 2011 6:26 am
Location: Markham, Ontario, Canada
Contact:

TCP/IP connection to .NET

Postby rudzitis » Fri Nov 09, 2018 2:13 am

Hi,

Is it possible for me to use TCP connection to call to .NET. I am setup a sample TCP IP server on .NET. Can someone tell me what I am doing wrong here?

I am trying to send message va CnTcpConnection but getting the following error:
2018/11/05 12:16:14.990: >>>>:AA/193: Error=31011 : Connection invalid state for requested operation : last action : Write
2018/11/05 12:16:14.990: >>>>:AA/193: Wrong connection state for cnOpen : state=1
2018/11/05 12:16:16.003: >>>>:AA/193: TCP error on connection #1 : client host was localhost on port 8888
2018/11/05 12:16:16.004: >>>>:AA/193: Error=31004 : Connection failed to connect : last action : Open


JADE CODE:

vars
vTCP : CnTcpConnection;
begin
app.initialize;
create vTCP transient;
vTCP.close;
vTCP.cnOpen('localhost',8888, vTCP);
vTCP.cnWrite('test'.Binary, vTCP);


.NET CODE

TcpListener serverSocket = new TcpListener(8888);
int requestCount = 0;
TcpClient clientSocket = default(TcpClient);
serverSocket.Start();
Console.WriteLine(" >> Server Started");
clientSocket = serverSocket.AcceptTcpClient();
Console.WriteLine(" >> Accept connection from client");
requestCount = 0;

Thaban

allistar
Posts: 156
Joined: Fri Aug 14, 2009 11:02 am
Location: Mount Maunganui, Tauranga

Re: TCP/IP connection to .NET

Postby allistar » Fri Nov 09, 2018 6:54 am

Use "netstat" in a command prompt to confirm that the .NET app is listening on the port. The command:

netstat -anop TCP

will show you all open TCP ports on the local computer and which process "owns" the connection. You should see any entry for port 8888 with a status of "LISTENING". If you don't then this is an issue with the .NET application. If you do then try and telnet to it:

telnet localhost 8888

If that opens a connection then the issue is most likely with the Jade code, if it doesn't then it's with .NET.

I personally would avoid the Cn class for this and instead use TcpIpConnection, at least until you can prove the connection works. Use non async calls to start with (as they're easier) and set a short time out (2 seconds). When using this in a real application it's better to use async calls as they're non blocking. Sync calls work as long as you use an exception handler to handle timeouts.

Hope this helps.

User avatar
rudzitis
Posts: 8
Joined: Tue Jan 11, 2011 6:26 am
Location: Markham, Ontario, Canada
Contact:

Re: TCP/IP connection to .NET

Postby rudzitis » Fri Nov 09, 2018 7:49 am

Thanks for your help.

I think the issue was the IP server. Even though I ran this on the thin client app, the system recognizes the 'localhost' as the server side. When I ran the .NET app on the server host, the localhost called worked.

Thaban

User avatar
BeeJay
Posts: 312
Joined: Tue Jun 30, 2009 2:42 pm
Location: Christchurch, NZ

Re: TCP/IP connection to .NET

Postby BeeJay » Fri Nov 09, 2018 8:22 am

I think the issue was the IP server. Even though I ran this on the thin client app, the system recognizes the 'localhost' as the server side. When I ran the .NET app on the server host, the localhost called worked.
If you need this to open the port on the presentation client machine, check out the TcpIpConnection::usePresentationClient property.

Cheers,
BeeJay.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 36 guests

cron