TCP burst to hostname
TCP burst to hostname
Hi,
I need help with SBL2e TCP communication. For a first time I used TCP client example to send some test string to server. Everything is working good but I need to send TCP burst to hostname not directly to IP address. Is this possible ?
Can you send TCP data to some hostname.com:1000 ? Is any way to programme this to SBL2e ?
Thank you for the support.
Best regards,
Blaž
I need help with SBL2e TCP communication. For a first time I used TCP client example to send some test string to server. Everything is working good but I need to send TCP burst to hostname not directly to IP address. Is this possible ?
Can you send TCP data to some hostname.com:1000 ? Is any way to programme this to SBL2e ?
Thank you for the support.
Best regards,
Blaž
Re: TCP burst to hostname
You need to use DNS to convert name to ip address....
All IP traffic is converted from name to ip address before its sent....
#include <dns.h>
/*
GetHostByName
Returns:
#define DNS_OK (0)
#define DNS_TIMEOUT (1)
#define NDS_NOSUCH_NAME (2)
*/
/* Pass 0 in for dns_server and it uses the stored value */
int GetHostByName( const char *name, IPADDR *pIpaddr, IPADDR dns_server, WORD timeout, WORD TYPE = DNS_A );
so suppose you have
const char * hostName="www.somehost.com";
IPADDR Address_of_host;
if(GethostByName(hostName,&Address_of_host,0,5*TICKS_PER_SECOND)==DNS_OK)
{//Successfully resolved name... now to use it
//Address_of_host holds the ip address.
}
else
{//Failed to resolve name....
}
All IP traffic is converted from name to ip address before its sent....
#include <dns.h>
/*
GetHostByName
Returns:
#define DNS_OK (0)
#define DNS_TIMEOUT (1)
#define NDS_NOSUCH_NAME (2)
*/
/* Pass 0 in for dns_server and it uses the stored value */
int GetHostByName( const char *name, IPADDR *pIpaddr, IPADDR dns_server, WORD timeout, WORD TYPE = DNS_A );
so suppose you have
const char * hostName="www.somehost.com";
IPADDR Address_of_host;
if(GethostByName(hostName,&Address_of_host,0,5*TICKS_PER_SECOND)==DNS_OK)
{//Successfully resolved name... now to use it
//Address_of_host holds the ip address.
}
else
{//Failed to resolve name....
}
Re: TCP burst to hostname
My code:
I always get Faild to resolve name ? Did I make any mistake ? What could be wrong ? And why do I have MyIpDNS varible null ?
Best regards,
Code: Select all
const char * AppName = "Test";
const char * hostName= "test.domain.com";
void UserMain(void *pd)
{
SimpleUart(0,SystemBaud); // Initialize debug UART
assign_stdio(0); // Use UART 0 for STDIO
InitializeStack(); // Initialize TCP stack
EnableAutoUpdate(); // Enable network downloads to target
OSChangePrio( MAIN_PRIO ); // set standard UserMain task priority
iprintf( "Starting test program\r\n" );
IPADDR Address_of_host = AsciiToIp("91.223.182.54");
while ( 1 )
{
OSTimeDly( 1 );
if( GetHostByName(hostName,&Address_of_host,0,5*TICKS_PER_SECOND) == DNS_OK)
{
iprintf( "Address_of_host holds the ip address.\r\n" );
}
else
iprintf( "Failed to resolve name...\r\n" );
}
}
Best regards,
Re: TCP burst to hostname
Are you using DHCP or a static address?
If its a static address did you give it a DNS server and gateway address?
If its a static address did you give it a DNS server and gateway address?
Re: TCP burst to hostname
Hi,
I am using static and now I got DNS figure it out. Now is working. Thank you for the help.
But still I got one question more. I want to send data to server trough TCP communication. But there is one trick. The server is listening for data but not answering. So if I use TCP Client example I got errors!
I cant use tcp.Connect(DestIP, DestPort, 40) because I always get false connection! I want to do this:
tcp.Connect(DestIP, DestPort, 40)
tcp.Printf("This message is from the TCP Server\r\n" );
tcp -> Output answer from server!
tcp.Close();
Can I use some code from examples or how to do this ?
I am using static and now I got DNS figure it out. Now is working. Thank you for the help.
But still I got one question more. I want to send data to server trough TCP communication. But there is one trick. The server is listening for data but not answering. So if I use TCP Client example I got errors!
I cant use tcp.Connect(DestIP, DestPort, 40) because I always get false connection! I want to do this:
tcp.Connect(DestIP, DestPort, 40)
tcp.Printf("This message is from the TCP Server\r\n" );
tcp -> Output answer from server!
tcp.Close();
Can I use some code from examples or how to do this ?
Re: TCP burst to hostname
Hi,
Any solution on my question ?
Best regards,
Any solution on my question ?
Best regards,
Re: TCP burst to hostname
Hello,
I think its a language thing, but your question does not make sense to me and you have not provided nearly enough information for anyone to help you.
What is a "false" connection? Does it seem to be connected but is not, or are you getting an error that the connection failed? What is the error code if it fails?
What type of server are you connecting to? Can you connect to it using telnet and the appropriate port number?
When you do a wireshark trace what do you see?
I think its a language thing, but your question does not make sense to me and you have not provided nearly enough information for anyone to help you.
What is a "false" connection? Does it seem to be connected but is not, or are you getting an error that the connection failed? What is the error code if it fails?
What type of server are you connecting to? Can you connect to it using telnet and the appropriate port number?
When you do a wireshark trace what do you see?
Re: TCP burst to hostname
Hi,
Now the communication is working. There was bug on server!
Thank you for the help.
Now the communication is working. There was bug on server!
Thank you for the help.
Re: TCP burst to hostname
Hi,
I got problems with DNS again! I cant get IP addres from hostname!
My network configuration:
IP: 192.168.1.254
255.255.255.0
192.168.1.1.
192.168.1.10 // DNS server
code:
I always get error 3! or in this case "DNS error!"
Thank you for the help.
I got problems with DNS again! I cant get IP addres from hostname!
My network configuration:
IP: 192.168.1.254
255.255.255.0
192.168.1.1.
192.168.1.10 // DNS server
code:
Code: Select all
#include <dns.h>
const char * hostName="www.google.com";
IPADDR Address_of_host = 0;
if(GetHostByName(hostName,&Address_of_host,0,5*TICKS_PER_SECOND) == DNS_OK)
{
iprintf("IP address: %I\r\n", hostName );
}
else
{
iprintf("DNS error!\r\n" );
}
Thank you for the help.
Re: TCP burst to hostname
Then the problem is your DNS server... Given that it is a from an address block reserved for DHCP, I'm assuming that you control the DNS server. Either that, or you are pointing to the wrong address. What happens if you try to set your PC's DNS server to that address? Can you still browse the internet?
If the address is correct and you can successfully talk with the DNS server, then the issue lies in your configuration of the DNS server. The problem is probably one of two things: a) you have setup the DNS server as a Fully resolving, caching nameserver or b) if you've setup the DNS server as DNS forwarder, you don't have a forwarding address set.
If you find that DNS requests are majorly delayed, but eventually return, then you likely have the first problem. Change the server to be a DNS forwarder, and it should resolve the issue. If you find that DNS requests are failing as unresolvable, then you probably have the second issue. In this case, you need to explicitly set the address of the server(s) to forward DNS requests to.
-Dan
If the address is correct and you can successfully talk with the DNS server, then the issue lies in your configuration of the DNS server. The problem is probably one of two things: a) you have setup the DNS server as a Fully resolving, caching nameserver or b) if you've setup the DNS server as DNS forwarder, you don't have a forwarding address set.
If you find that DNS requests are majorly delayed, but eventually return, then you likely have the first problem. Change the server to be a DNS forwarder, and it should resolve the issue. If you find that DNS requests are failing as unresolvable, then you probably have the second issue. In this case, you need to explicitly set the address of the server(s) to forward DNS requests to.
-Dan
Dan Ciliske
Project Engineer
Netburner, Inc
Project Engineer
Netburner, Inc