views:

26

answers:

1

Hi

I have an SMS Appliaction, which receives the messages through GPS Modem and revert back through GPS Modem. The Modem is using COM1.

Now, i need two more appliactions which can send messages through the same GPS Modem. I tried making a webservice which can access the COM1 to send data, but when i try to connect through webService, it throw an error saying, 'COM1 is already occupied, Access denied.'.

Can anybody help me to connect through the modem in above scenario.

Khushi

+1  A: 

You have to make sure only 1 connection is made.

Easiest (and most low-tech, but probably most flexible) is having a script checking a directory for files regularly and sending the messages in the file to the modem. The webservice then just writes a file for every SMS it received. (this can be trivially extended to accept emails, web requests, etc, ...)

A bit more sophistacated is to start a thread to do the communication and push the messages on a FIFO like datastructure provided by your favorite programming platform. A BlockinQueue would be perfect. The thread reads the messages from the queue and sends them to the GSM modem.

If you want to have confirmation the SMS is sent (which in my experience does not mean anything and certainly not that the recipient actually received it) you'll need to find a way to return feedback to the caller. This can be as simple a setting a boolean flag in the message to sending another message or performing a callback. But I would not bother. I had situations where 30% of messages dissapeared even when we had confirmation of the message central.

Peter Tillemans
is there any other way doing this thing, something like creating COM component or some centralized dll ?
Khushi
Yeah, sure. But neither a shared DLL or a COM object will solve the basic problem of serializing requests to the GSM modem. To get that right you need to do locking (bad idea, do not do locking, this road leads to deadlocks, performance problems and unrepeatable issues) or use 1 thread/process to talk to the gps/gsm-modem and handling requests 1 by 1. You can talk to it through files, named pipes, RPC, com calls, shared memory, whatever suits your need best or any combination for that matter.
Peter Tillemans