Home » SQL Server

GPRS Communication using GSM Mobile

Dear all, 

I am working on a project which involves send messages through GPRS modem to a specified server port(having static IP).

I need .net code to send data through GPRS modem to server's specified port. If anyone having experience in this area please guide me.




6 Answers Found


Answer 1


In this moment, I'm working  on  the same project  too, gprs  data is datagram packets, so we need a UDP socket that listens in an specific IP  and  port, to test, i began by writing console application in C#, i launched it in my VPS,

        private const int UdpPort = 8002;  
        private const string sIPAdress = "A.B.C.D";

        public GpsListner()

        public void Inits()
                UdpThread = new Thread(new ThreadStart(StartReceive));
                Console.WriteLine("AStarted GPS Server");
            catch (Exception ex)
                Console.WriteLine("An UDP Exception has occurred!" + ex.ToString());



        public void StartReceive()

                IPEndPoint localIpEndPoint = new IPEndPoint(IPAddress.Parse(sIPAdress), UdpPort);
                UdpClient Udp = new UdpClient(localIpEndPoint);
                Console.WriteLine("Start to Receive on :" + sIPAdress, EventLogEntryType.Information);

                while (true)
                    Console.WriteLine("In Loop", EventLogEntryType.Information);
                    IPEndPoint tmpIpEndPoint = new IPEndPoint(IPAddress.Parse(sIPAdress), UdpPort);
                    EndPoint remoteEP = (tmpIpEndPoint);
                    Byte[] received = Udp.Receive(ref tmpIpEndPoint);
                    String device_id = null;
                    Console.WriteLine("GPS is connected through UDP From: " + tmpIpEndPoint.ToString() + "\n" + BitConverter.ToString(received) + "\n" + "Packet Size :" + received.Length, EventLogEntryType.Information);


            catch (SocketException se)
                Console.WriteLine("A Socket Exception has occurred!" + se.ToString());



Now, when i send  an asynchronous string remotly from a client socket, the socket server  catch the data  but when sending packets from gprs unit nothing happens

I hope that we can find a solution together


Thank you  


Answer 2


Thanks for your response.

The problem is transmission from modem  itself. I successfully tested the modem for sending SMS over gprs. As we mentioning the SMSC to send  SMS it reaches safely to the required mobile.

We don't verify whether the data  was transmitted over gprs  or not. While try to send data over gprs to a specified server, in my guess it should pass through mobile  operator's server  and proxy (atleast for connection establishment). When I queried to mobile operators, they told there is no block in their side.

 I am working  for last three days only to fix this problem. Please update if you get any improvements. I always believe 'Teamwork works'.



Answer 3

HI shanchin2k,

I suggest you take a research gsmcomm 3rd party component, which provide the function to send  SMS. For more information:





Best regards,
Guang-Ming Bian - MSFT


Answer 4

 Dear Guang-Ming Bian,

   Thanks for your reply. I already succeeded with SMS sending but it is some what costlier solution. I need a solution at the server  end which receive the GPRS data  through a port.

  Both TCP/IP and UDP packets are tested manually but while sending through GPRS there is no symptoms at the server end.




Answer 5

Please you help me.

We're programming on the mobile  platform and the tools as follows:
Windows Mobile 6.0 operating system, programming with Windows Mobile 6.0 SDK, used in the ActiveSync 4.5,  Emulator and Windows Mobile 6.0 SDK propessional provided. Work on the Windows XP SP2.
My job is programming applications GPRS technology to send  data over the network from a mobile phone to a server  (with public IP). But now I do not have server so I need to set up your computer simulation is a server. But I do not know the settings for computers and phones in the Emulator is installed on it to communicate with each other through network protocols. hope you help me. I am very need.


Answer 6


Please you help me.

We're programming on the mobile  platform and the tools as follows:
Windows Mobile 6.0 operating system, programming with Windows Mobile 6.0 SDK, used in the ActiveSync 4.5,  Emulator and Windows Mobile 6.0 SDK propessional provided. Work on the Windows XP SP2.
My job is programming applications GPRS technology to send  data over the network from a mobile phone to a server  (with public IP). But now I do not have server so I need to set up your computer simulation is a server. But I do not know the settings for computers and phones in the Emulator is installed on it to communicate with each other through network protocols. hope you help me. I am very need.



It's long,  Have you got the answer? I'm still concerned about it. Thank you!



hi All

I working as a Dotnet Developer, I need to develop GPRS module, i do know about GPRS communication using dot net. Please guide me and send me the sample coding for communicate in GPRS.

Many thanks in Advance.

K. Govindaraj




Hi experts,

I am a c# programmer and I am new to TAPI. I would like to call 2 numbers and setup a conference call. My mobile supports conferencing feature. I am trying to use openNetCF 2.0 wrapper for TAPI  but I am unable to identify required functions.

 Can you please suggest me how I can implement this functionality using C#. Is there any specific wrapper I need to use or any mechanism I need to follow? Please advise.

Kind Regards,




I have a mobile application that calls a webservice, but I am getting the error "Unable to read data from the transport connection" when calling the webservice.

Note that when using a wi-fi connection, it works just fine! Also connection to the internet with the mobile device is good - can access the asmx page of the webservice.

Any help of what could the problem be?



I need to write a tool that logs the amount of network traffic on a windows mobile 6.5.

The network may be GPRS/WWAN/HDSPA etc.

Is this a feasible assignment?


Best Regards,

Gurjeet Singh 



I'm trying to connect to TCP socket (port 12345) from windows mobile 6.5 c# application.  It works perfectly when device is connected to computer with activesync, also works fine in the emulator. Internet Explorer on WM works fine, also the application connects fine when using port 80. Surely it is not because of firewall or sth on SIM card or wireless operator network because the same SIM card allows connecting port 12345 from other device. The problematic device is HTC Touch 2.

The code is like this: http://blogs.msdn.com/b/anthonywong/archive/2006/03/13/550686.aspx but the port is changed. I also tried plain Socket (without tcpclient) but it didn't help. I get SocketException.

Please help!!



I have Windows Mobile 6.1 client written with C# .NET Compact Framework v 3.5.  This client needs to make an SSL socket connection back to a server.  With the SSLStream class not part of the CF, making such a socket connection is not easy to do.  Does anyone have sample code on how to make this work? 

I tried using this nice article, but it throws a socket exception every time when I try to do socket.SetSocketOption(...):

I have also tried following this article, but it refers to the use of SO_SECURE and SO_SEC_SSL, items that don't exist in the Compact Framework.


Thanks for any help you can provide.


Hi all,

I have developed a windows application using C# (.NET 3.5)   which needs to communicate with hand-held application C# (.NET 3.5). Communication is wireless and is exchange of XML files. As per requirement Hand held gets 5 to 7 XML files from server (desktop application running on a server). these are XML files and definitely contain the data to be used by hand held application. After processing on these files by hand held application it sends these updated files back to server (Desktop application). Help me to get out of it. This is basic and most important of this application. Thanks in Advance.



Could anybody give me code to connect with GSM mobile and send sms through it?




i want to create an application for send sms to mobile phones using my .net applciation..


is there any way to do it?




Hi to all,

I need to make an application that can send sms from a desktop pc using a windows mobile phone as a gsm modem. It can be a desktop app or a web app. 

The mobile phone is connected via USB. 

I don't want to use third party sms gateways.

Can you point me in the right direction?

Thanks in advance

Hi everyone,

My phone HTC HD is using WM6. Generaly a phone can capture the signal of 7 surrounding cells (GSM/3G). Is it possible to connect to a cell's network by giving some parameters (as frequency band, cell ID ...) of the cell ?

Any suggestion about an existed Windows tool/program, a C/C++ code bloc ... will all be great.


Dear Friends,

I am in trouble in creating an application that sends and receives sms using my cellphone connected to the computer(using a gsm modem). I just don't want to use a web service / third party applications that cost at all. Just like a simple c# windows application that sends and receive sms. I tried to explore google, codeproject, etc but they use web services, third party and gateways. And applications that I downloaded dont work at all.

I already installed the modem in my computer. What i am needing for now is the application.

Anybody can guide me...

In advance your help is appreciated. Thanks.




I am developing SMS Application in C# .net

AND i need to check that do i have a gsm modem or not?

how do i check it pro-grammatically?



how do i send data using the data channel aka CSD of the GSM network. This is urgent, please help

Hi All,

I have a an application through which I am sending and receiving SMS using GSM Modem. I want to receive Delivery Reports when a message is delivered successfully at the receiver's end.

I have tested the GSM modem through hyper terminal using the following commands

AT+CSMP=49,167,0,0 <CR>


AT+CNMI=2,2,0,1,0 <CR>


AT+CMGS="[phoneNumber]" <CR>
> Message content <ctrl Z>
+CMGS: 72


+CDS:6,72,"[phoneNumber]" ,129,"08/11/17,10:16:18+22" , "08/11/17,10:16:21+22" , 0

I am able to receive delivery reports as shown above until a new message indication arrives.
After that delivery reports indications are not forwarded from the modem to the Hyper terminal.

+CMT:  "+[PhoneNumber]" , , "08/11/17, 11:59:28+22"
New Message contents

I find that the parameters for CNMI have changed

+CNMI: 2,0,0,0,0

Please could you explain why this is happening? I would like to know how to receive delivery reports without affecting the new message indications.

Thanks in advance

Hello Friends,
I have got this much till now,

1) Sending AT commands to Serial port which connects to GSM MODEM, it works well with Hyperterminal.
2) Sending SMS Message through VB.NET using AT Commands.
3) Receiving SMS Message through VB.NET using AT Commands.

But my problem is,
1) Whenever i send SMS to GSM modem that SMS message has to be pushed to my PC.[this will work if i write a button click event sending AT command to retrieve SMS]
but i don't want it to happen user event driven.
GSM modem should automatically send the sms that it receives.(It means our application must keep listening to the port)

I need help in these points,
1) How to make GSM MODEM send SMS Message that it receives automatically to RS232 serial port[COM3]
2) How to listen to a particular port say COM3 for incoming messages.

i need some help with respect to coding part.
Thanks in advance.

Is there any way to power on/off modem GSM in my c# .net ce 3.5 application?


Best regards,



Hy Hope you are all fine and enjoying a good health.

I am developing a project to send and receive data over voice call through GSM Network.I need a answer of question that "WHAT  is the baud rate of GSM Network for sending a data in voice call ?"

Or Simply says that when we call to another person , how much baud rate is consumed by GSM network? or in which baud rate data is voice is transmitted?


Reply me as soon as possible.


Hi,I trying to interface a  gsm modem with computer via visual c++. I've created a serial comunication but I don't now if is ok because I get no answer from the modem. Here is my code:

/ TrimitSMSDlg.cpp : implementation file

#include "stdafx.h"
#include "TrimitSMS.h"
#include "TrimitSMSDlg.h"

#ifdef _DEBUG
#define new DEBUG_NEW

// CAboutDlg dialog used for App Aboutclass CAboutDlg : public CDialog

// Dialog Dataenum { IDD = IDD_ABOUTBOX };

	virtualvoid DoDataExchange(CDataExchange* pDX);  // DDX/DDV support// Implementationprotected:

CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)

void CAboutDlg::DoDataExchange(CDataExchange* pDX)


// CTrimitSMSDlg dialog

CTrimitSMSDlg::CTrimitSMSDlg(CWnd* pParent /*=NULL*/)
	: CDialog(CTrimitSMSDlg::IDD, pParent)
	m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);

void CTrimitSMSDlg::DoDataExchange(CDataExchange* pDX)
	DDX_Control(pDX, IDOK, m_OK);
	DDX_Control(pDX, IDCANCEL, m_Cancel);
	DDX_Control(pDX, IDC_InitSer, m_InitCom);
	DDX_Control(pDX, IDC_SEND_DATA, m_SendData);
	DDX_Control(pDX, IDC_CLOSE_SER, m_Close);

	ON_BN_CLICKED(IDC_InitSer, &CTrimitSMSDlg::OnBnClickedInitser)
	ON_BN_CLICKED(IDC_SEND_DATA, &CTrimitSMSDlg::OnBnClickedSendData)
	ON_BN_CLICKED(IDC_CLOSE_SER, &CTrimitSMSDlg::OnBnClickedCloseSer)

// CTrimitSMSDlg message handlers

BOOL CTrimitSMSDlg::OnInitDialog()

	// Add "About..." menu item to system menu.// IDM_ABOUTBOX must be in the system command range.

	CMenu* pSysMenu = GetSystemMenu(FALSE);
	if (pSysMenu != NULL)
		CString strAboutMenu;
		if (!strAboutMenu.IsEmpty())
			pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);

	// Set the icon for this dialog. The framework does this automatically// when the application's main window is not a dialog
	SetIcon(m_hIcon, TRUE);			// Set big icon
	SetIcon(m_hIcon, FALSE);		// Set small icon// TODO: Add extra initialization herereturn TRUE; // return TRUE unless you set the focus to a control

void CTrimitSMSDlg::OnSysCommand(UINT nID, LPARAM lParam)
	if ((nID & 0xFFF0) == IDM_ABOUTBOX)
		CAboutDlg dlgAbout;
		CDialog::OnSysCommand(nID, lParam);

// If you add a minimize button to your dialog, you will need the code below// to draw the icon. For MFC applications using the document/view model,// this is automatically done for you by the framework.void CTrimitSMSDlg::OnPaint()
	if (IsIconic())
		CPaintDC dc(this); // device context for painting

		SendMessage(WM_ICONERASEBKGND, reinterpret_cast<WPARAM>(dc.GetSafeHdc()), 0);

		// Center icon in client rectangleint cxIcon = GetSystemMetrics(SM_CXICON);
		int cyIcon = GetSystemMetrics(SM_CYICON);
		CRect rect;
		int x = (rect.Width() - cxIcon + 1) / 2;
		int y = (rect.Height() - cyIcon + 1) / 2;

		// Draw the icon
		dc.DrawIcon(x, y, m_hIcon);

// The system calls this function to obtain the cursor to display while the user drags// the minimized window.
HCURSOR CTrimitSMSDlg::OnQueryDragIcon()

HANDLE hSerPort1;

void CTrimitSMSDlg::OnBnClickedInitser()
	DWORD errVal;
	//(LPCWSTR)"COM1" - aiurea nu mergewchar_t portName[] = {L"COM1"}; //merge doar asa

	hSerPort1 = CreateFile( portName, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, 0, NULL);

		AfxMessageBox(_T("Nu am putut deschide portul serial !!!!"), 0, MB_OK);
		//setare temporizari comunicatie
		COMMTIMEOUTS comTimeOut;          

		comTimeOut.ReadIntervalTimeout = 3;
		comTimeOut.ReadTotalTimeoutMultiplier = 3;
		comTimeOut.ReadTotalTimeoutConstant = 2;
		comTimeOut.WriteTotalTimeoutMultiplier = 3;
		comTimeOut.WriteTotalTimeoutConstant = 2;

		if(!SetCommTimeouts(hSerPort1, &comTimeOut))
			AfxMessageBox(L"Nu am putut seta param. temporali ai portului !!!!", 0, MB_OK);

		//setara param. si mod comunicatie
		DCB dcb; // device block controlif ( !GetCommState(hSerPort1, &dcb) )	//If the function fails, the return value is zero
			AfxMessageBox(L"Nu am putut lua param. si caract. portului !!!!", 0, MB_OK);

		dcb.DCBlength = sizeof(dcb);
		dcb.BaudRate = 115200;
		dcb.fBinary = 1;
		dcb.fParity = 1;						//daca TRUE atunci paritatea este verificata si //mesaje de erori sunt generate - daca sunt
		dcb.fOutxCtsFlow = 0;
		dcb.fOutxDsrFlow = 0; 
		dcb.Parity = ODDPARITY;			//0-4= no, odd, even, mark, space//NOPARITY, ODDPARITY, EVENPARITY, MARKPARITY, SPACEPARITY
		dcb.StopBits = ONESTOPBIT;   //0,1,2 = 1, 1.5, 2 - ONESTOPBIT, ONE5STOPBITS, TWOSTOPBITS 
		dcb.ByteSize = 8;
		dcb.fNull = 0;					//If this member is TRUE, null bytes are discarded //when received.if( !SetCommState(hSerPort1, &dcb) )  //If the function fails, the return value is zero
			AfxMessageBox(L"Nu am putut seta param. si modalitatile realiz. comunicatiei !!!!", 0, MB_OK);


		//errVal = GetLastError(); //pt. a prelua eroare ultima

void CTrimitSMSDlg::OnBnClickedSendData()
	// TODO: Add your control notification handler code herechar bufferSer[100];
	DWORD sizeBuffer; //numarul de octeti ce trebuie scrisi in port
	DWORD sizeWritten;   //numarul de octeti scrisi real in port//trimit textulchar txt[] = {"at\r"};

	strcpy_s( bufferSer, 100, txt);
	sizeBuffer = strlen( bufferSer );

	if ( WriteFile(hSerPort1, bufferSer, sizeBuffer, &sizeWritten, NULL) == 0 )
	//	AfxMessageBox(L"Nu am putut scrie informatia in port !!!!", 0, MB_OK);//afisez textul
	bufferSer[0] = 10;
	sizeBuffer  = 1; 

	if ( WriteFile(hSerPort1, bufferSer, sizeBuffer, &sizeWritten, NULL) == 0 )
		AfxMessageBox(L"Nu am putut scrie informatia in port !!!!", 0, MB_OK);

void CTrimitSMSDlg::OnBnClickedCloseSer()
	if(CloseHandle(hSerPort1) == 0)  
		AfxMessageBox(L"Nu am putut inchide portul serial !!!!", 0, MB_OK);

//	m_ClearBut.EnableWindow(FALSE);//	m_LEDOnOff.EnableWindow(FALSE);

Dear fellow, I am developing a chat application for windows mobile 5.0 to 7.0. My application works fine when the device is in woke up (back light on) mode. But in the sleep (back light off) mode it fails. my question is how can i overcome this issue. I think in sleep mode socket receive dose not work. Thanks. Regards, Shuvo.

<< Previous      Next >>

Microsoft   |   Windows   |   Visual Studio   |   Sharepoint   |   Azure