I want to send SMS from my PC using a GSM modem. I have used this example and I can send SMS. I want to use a loop to SMS to many users, but it doesn't work.
My error:
sms.SerialConnectionException: Port currently owned by SMSConnector
at sms.SerialConnection.openConnection(SerialConnection.java:93)
at sms.Sender.send(Sender.java:42)
at sm开发者_开发百科s.SMSClient.run(SMSClient.java:43)
at java.lang.Thread.run(Thread.java:595)
I don't know anything about sending SMSs from your PC, but I have two suggestions.
- It looks like the connection is still open. Try closing it and reopenning it before sending a new SMS?
- If that doesn't work, it might have some lock in place to prevent you from spamming people with SMSs. Try putting some sort of
wait()
orsleep()
command in your loop to bypass it.
this doesn't really answer your question, i know, but i find using a hosted solution much easier. the one i use is clickatell which is pretty cheap, easy and reliable. this way, you don't need to use any half baked sms apis (such as the one you are using) and you don't need any extra hardware like a GSM modem. the only downside is that if your network goes down you can't send sms.
精彩评论