Can you provide a sample code to add multiple modems dynamically ?
On Mon, Nov 14, 2011 at 12:45 PM, Lajeev Rajan <[email protected]> wrote:
> Getting the same error :(
>
> I changed the code like this
>
> Comm2IP.Comm2IP com1 = new Comm2IP.Comm2IP(new byte[] { 127, 0, 0, 1 },
> 120+i, PortName, Convert.ToInt32(BoaudRate));
>
> and
>
> gateway[i] = new IPModemGateway(dt.Rows[i][0].ToString(),"127.0.0.1",
> 120+i, dt.Rows[i][0].ToString(), "");
>
> Thanks.
> Lajeev.
>
> On Mon, Nov 14, 2011 at 12:37 PM, Lajeev Rajan <[email protected]> wrote:
>
>> Thanks .
>>
>> Let me check and comeback to you.
>>
>> On Mon, Nov 14, 2011 at 12:35 PM, Nick Chan <[email protected]> wrote:
>>
>>> instead of this,
>>> Comm2IP.Comm2IP com1 = new Comm2IP.Comm2IP(new
>>> byte[] { 127, 0, 0, Convert.ToByte(i + 1) }, 12000, PortName....
>>>
>>> do this
>>> Comm2IP.Comm2IP com1 = new Comm2IP.Comm2IP(new
>>> byte[] { 127, 0, 0, 1}, 120 + i, PortName....
>>>
>>>
>>>
>>> On Mon, Nov 14, 2011 at 4:33 PM, Lajeev Rajan <[email protected]> wrote:
>>>
>>>> Thanks for your immediate reply.
>>>>
>>>> Sorry I did n't get you :( can you explain briefly ...
>>>>
>>>>
>>>> Thanks.
>>>> Lajeev
>>>>
>>>> On Mon, Nov 14, 2011 at 12:06 PM, Nick Chan <[email protected]>wrote:
>>>>
>>>>> are u sure u have that many internal IPs ?
>>>>>
>>>>> Comm2IP.Comm2IP com1 = new Comm2IP.Comm2IP(new
>>>>> byte[] { 127, 0, 0, Convert.ToByte(i + 1) }, 12000, PortName,
>>>>> Convert.ToInt32(BoaudRate));
>>>>>
>>>>> iterate the Port , not IP
>>>>>
>>>>> On Mon, Nov 14, 2011 at 3:42 PM, Leji <[email protected]> wrote:
>>>>>
>>>>>> How do I connect multiple modems ?? (smslib.net-v3.4.5)
>>>>>>
>>>>>> I am developing a web service to read messages from GSM/GPRS Modem.
>>>>>> User can configure N number of modems.The modem information will fetch
>>>>>> from an xml file. following are my code.
>>>>>>
>>>>>> // Fetch Modem details from XML File
>>>>>>
>>>>>> DataTable dt = AppUtility.getAllModem(FilePath, "Modem
>>>>>> Configuration");
>>>>>>
>>>>>>
>>>>>>
>>>>>> for (int i = 0; i < dt.Rows.Count; i++)
>>>>>> {
>>>>>>
>>>>>> if (dt.Rows.Count > 0)
>>>>>> {
>>>>>> string PortName = dt.Rows[i][1].ToString();
>>>>>> string BoaudRate = dt.Rows[i][2].ToString();
>>>>>>
>>>>>> Comm2IP.Comm2IP com1 = new Comm2IP.Comm2IP(new
>>>>>> byte[] { 127, 0, 0, Convert.ToByte(i + 1) }, 12000, PortName,
>>>>>> Convert.ToInt32(BoaudRate));
>>>>>> new Thread(new ThreadStart(com1.Run)).Start();
>>>>>>
>>>>>> }
>>>>>>
>>>>>>
>>>>>> }
>>>>>>
>>>>>>
>>>>>> //Create new Service object - the parent of all and
>>>>>> the main interface to you.
>>>>>> srv = new Service();
>>>>>>
>>>>>> // Lets set some callbacks.
>>>>>> srv.setInboundMessageNotification(new
>>>>>> InboundNotification());
>>>>>> srv.setCallNotification(new CallNotification());
>>>>>> srv.setGatewayStatusNotification(new
>>>>>> GatewayStatusNotification());
>>>>>>
>>>>>> // Create the Gateway representing the serial GSM
>>>>>> modem.
>>>>>> // Due to the Comm2IP bridge, in SMSLib for .NET all
>>>>>> modems are considered IP modems.
>>>>>>
>>>>>> IPModemGateway[] gateway=new IPModemGateway[10];
>>>>>>
>>>>>> for (i = 0; i < dt.Rows.Count; i++)
>>>>>>
>>>>>> {
>>>>>>
>>>>>> if (dt.Rows.Count > 0)
>>>>>> {
>>>>>> int IPEnd = i + 1;
>>>>>> string IP = "127.0.0." + IPEnd;
>>>>>>
>>>>>>
>>>>>> gateway[i] = new IPModemGateway(dt.Rows[i]
>>>>>> [0].ToString(),IP, 12000, dt.Rows[i][0].ToString(), "");
>>>>>>
>>>>>>
>>>>>> gateway[i].setIpProtocol(ModemGateway.IPProtocols.BINARY);
>>>>>>
>>>>>> // Set the modem protocol to PDU (alternative
>>>>>> is TEXT). PDU is the default, anyway...
>>>>>>
>>>>>> gateway[i].setProtocol(AGateway.Protocols.PDU);
>>>>>>
>>>>>> // Do we want the Gateway to be used for
>>>>>> Inbound messages?
>>>>>> gateway[i].setInbound(true);
>>>>>>
>>>>>> // Do we want the Gateway to be used for
>>>>>> Outbound messages?
>>>>>> gateway[i].setOutbound(true);
>>>>>>
>>>>>> // Let SMSLib know which is the SIM PIN.
>>>>>> gateway[i].setSimPin("0000");
>>>>>>
>>>>>> // Add the Gateway to the Service object.
>>>>>> srv.addGateway(gateway[i]);
>>>>>>
>>>>>>
>>>>>>
>>>>>> }
>>>>>> }
>>>>>>
>>>>>> srv.startService();
>>>>>>
>>>>>>
>>>>>>
>>>>>> Above code I have got following error.
>>>>>>
>>>>>> An existing connection was forcibly closed by the remote host
>>>>>> Error Code: 10054
>>>>>> at org.smslib.Service.startService()
>>>>>> at SMSService.SMSService.OnStart(String[] args) in ...
>>>>>>
>>>>>>
>>>>>>
>>>>>> Whats wrong in my code. Please advice me.
>>>>>>
>>>>>> Thanks in advance.
>>>>>>
>>>>>> --
>>>>>> You received this message because you are subscribed to the Google
>>>>>> Groups "SMSLib Discussion Group" group.
>>>>>> To post to this group, send email to [email protected].
>>>>>> To unsubscribe from this group, send email to
>>>>>> [email protected].
>>>>>> For more options, visit this group at
>>>>>> http://groups.google.com/group/smslib?hl=en.
>>>>>>
>>>>>>
>>>>> --
>>>>> You received this message because you are subscribed to the Google
>>>>> Groups "SMSLib Discussion Group" group.
>>>>> To post to this group, send email to [email protected].
>>>>> To unsubscribe from this group, send email to
>>>>> [email protected].
>>>>> For more options, visit this group at
>>>>> http://groups.google.com/group/smslib?hl=en.
>>>>>
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "SMSLib Discussion Group" group.
>>>> To post to this group, send email to [email protected].
>>>> To unsubscribe from this group, send email to
>>>> [email protected].
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/smslib?hl=en.
>>>>
>>>
>>> --
>>> You received this message because you are subscribed to the Google
>>> Groups "SMSLib Discussion Group" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/smslib?hl=en.
>>>
>>
>>
>
--
You received this message because you are subscribed to the Google Groups
"SMSLib Discussion Group" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/smslib?hl=en.