GPRS conn using sockets

Hello all again.

I have two Fastrack modems which i’d like to comunicate via GPRS. I have a listening socket in one of them. The thing is that I need something to start the connection on the other when the modem starts. I’ve got all the IPs and data I need, but I just don’t know how to start the connection (an opening socket I think…)

Could anyone give me a hint about this? Thank you very much in advance.

Duplicate:
wavecom.com/modules/movie/sc … php?p=6507

Do a forum search for “Public IP Address”

Unless your devices have Public IP Addresses, or you have some special routing arrangement, or VPN, or something, it is unlikely that they will be able to communicate directly.

Sorry about the duplication. I didn’t know in which forum would best fit, i thought you would delete the improper one :slight_smile:.

There’s no harm in cross-posting provided you make it clear that you’ve done so, and provide links between the threads.

Probably better is to make a full post in just one thread, with a brief summary & link in the other.

Otherwise it just gets confusing, and people can waste time answering in one thread when exactly the same has already been said in the other

I have a public IP address, that’s not the problem. The thing is that I don’t know how to tell the listening socket that I want to create a channel to comunicate with it… Is there a command to do that?

Are you using WIP, or its predecessor, or what?

And what versions?

General Sockets tutorials & info:
world.std.com/~jimf/papers/sockets/sockets.html
frostbytes.com/~jimf/papers/ … nsock.html
michael.toren.net/mirrors/sock-f … faq-1.html

Oh!, sorry about that. I’m using WIP 3.00.07, OpenAT OS 3.13.02 and Firmware 657c. I’m pasting my socket, hope that might help…

void Hdlr_TCPSocket ( wip_event_t *Event, t2r_cx_state *ctx ) {

	u32 read;
	u32 write;
	u8 *DataBuffer;
	wip_channel_t wct_Channel;

	TRACE ( ( 1, "Hdlr_TCPSocket: Entering" ) );

	wct_Channel = Event->channel;

	TRACE ( ( 1, "Hdlr_TCPSocket: Channel: %d", Event->channel ) );

	//TRACE (( 1, "SpawnCanalServer en TCP_Handler: %d", SpawnCanalServer ));
	switch ( Event->kind ) {
		
		case WIP_CEV_READ:
			TRACE ( ( 1, "Hdlr_TCPSocket: WIP_CEV_READ" ) );
			if(ctx == (t2r_cx_state *) NULL)	{
			    
				u8 cadena[255];
				
				TRACE ( ( 1, "Hdlr_TCPSocket: ctx NULL" ) );
				sprintf ( cadena, "Socket Error. CTX NULL" );
				wip_write ( wct_Channel, cadena, (u32) strlen(cadena) );
				wip_close ( wct_Channel );
			}
			else {
				
				DataBuffer = adl_memGet ( ( Event->content.read.readable + 1 ) + 100 );
				wm_memset ( DataBuffer, 0x00, Event->content.read.readable );
				//(DataBuffer+read)='\0';
				// ctx->cx0 
				while ( ( read = wip_read ( ctx->cx0, DataBuffer, Event->content.read.readable ) ) > 0 ) { 

					DataBuffer[Event->content.read.readable] = '\0';
					TRACE ( ( 1, "Hdlr_TCPSocket: Read: %s", DataBuffer ) );
					// If RS232 port is open, data is sent
					if ( t2r_RS232_Open )
						adl_fcmSendData ( V24M_Handle, DataBuffer, Event->content.read.readable );

					//adl_atSendResponsePort(ADL_AT_UNS, ADL_PORT_UART1, DataBuffer); 
						
					//adl_atSendResponsePort(ADL_AT_UNS, ADL_PORT_UART1, "\r\n"); 
				} 
				adl_memRelease ( DataBuffer );
			}
			break;
	
		case WIP_CEV_WRITE:
			TRACE ( ( 1, "Hdlr_TCPSocket: WIP_CEV_WRITE" ) );
			break;

		case WIP_CEV_OPEN:
			TRACE ( ( 1, "Hdlr_TCPSocket:WIP_CEV_OPEN" ) );

			if( ctx == (t2r_cx_state *) NULL ) { // First conn

				// Looking for a free conn context
				u16 i;

				for ( i = 0; i < T2R_TCPMAXCLIENTE; i++ ) {

					if ( t2r_cx_table[i].state == T2R_FREE ) {

						ctx = (t2r_cx_state*) &t2r_cx_table[i];
						ctx->state = T2R_CONNECTED;
						ctx->cx0 = wct_Channel;

						wip_setCtx ( wct_Channel, ctx );

						TRACE ( ( 1, "Hdlr_TCPSocket: ctx NULL Opening RS232" ) );
						// As a channel has been opened, serial port data mode activates
						T2R_Start_RS232Comm ( );
					}
				}
				if ( i <= T2R_TCPMAXCLIENTE && ctx != (t2r_cx_state*) NULL ) {

					TRACE ( ( 1, "Hdlr_TCPSocket: Conn number %d", i - 1 ) );
					write = wip_write ( ctx->cx0, "Conected\n\r", 10 );
				}
				else {

					u8 cad[255];

					TRACE ( ( 1, "Hdlr_TCPSocket: Max number of connection reached" ) );
					
					sprintf ( cad, "Max number of connections reached\n\r" );
					write = wip_write ( ctx->cx0, cad, (u32) strlen ( cad ) );
					wip_close ( wct_Channel );
				}
			}
			else {

				// Context should be empty
				TRACE ( ( 1, "Hdlr_TCPSocket: Context is not null when openning connection" ) );
				wip_close ( wct_Channel );
			}
			break;

		case WIP_CEV_ERROR:
		case WIP_CEV_PEER_CLOSE:
			TRACE ( ( 1, "Hdlr_TCPSocket:WIP_CEV_PEER_CLOSE" ) );
			if ( ctx != (t2r_cx_state*) NULL && ctx->state == T2R_CONNECTED ) {

				wip_close ( ctx->cx0 );
				ctx->state = T2R_FREE;
			}
			else if ( ctx != (t2r_cx_state*) NULL )	{
				
				wip_close ( wct_Channel );
				ctx->state = T2R_FREE;
			}
			else {

			    wip_close ( wct_Channel );
			}
			T2R_CloseRS232 ( );
			break;

		default: 
			TRACE ( ( 1, "Hdlr_TCPSocket:Not Controlled error: %d", Event->kind ) );
			break;
		} 

}

Have you looked at the Socket samples for WIP supplied with the SDK?

I have heard about those examples, but i’ve looked for them for ages and i haven’t been able to find them… Could you help with that?

Under your Open-AT installation folder, you should have:

Plug-ins\WIP[i][/i]\WIP\samples

In that folder you should have the WIP Samples, with a sub-folder for each sample:

tcp_server - Puts a TCP server listening on the specified port. To every client connecting to that server, sends [snd_buffer], possibly in several chunks;

tcp_client - Connects a TCP client socket to the specified TCP server.

Each sample folder contains a readme HTML file that describes the sample.

For further details, contact your distributor.

Doesn’t “TCP/IP Plug-In & Internet Plug-In” sound the most obvious and directly relevant?!

wavecom.com/modules/movie/sc … m.php?f=16

It was not a bad idea to use those samples, but there is a little problem about them. I need “transparent” client and server, and new wavecom stack IP need some sort of acknowledgement when data is received… I’ve got the server, but i’m having some trouble with the client…