473,785 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

how to convert socket in linux to work on windows

5 New Member
I have a perl script for unix which uses a socket to read data from gsm modem connected to com port.I need to convert it to windows.I think most of the script is going to be same except the line which establishes the socket connection.
Could someone please help me to know which lines I should change so that it will work on windows.
Here is the script
#!/usr/bin/perl -w

# TRG: Perl script to exercise GSM card through a set of diagnostic commands
# The results from each command are sent back to the browser client
# Accesses the GSM card via gsmd socket (for sharing)

use strict;
use IO::Socket::UNI X;
use Term::ReadKey;
use IO::Select;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrow ser);

# Keep Apache happy with the content
print "Content-type: text/htmlnn";

# Open the socket connection to GSMD
my $sock = new IO::Socket::UNI X (Type => SOCK_STREAM,
Peer => '/home/glucose/gsm/gsmd_sock',
Timeout => 60) || die "Couldn't establish socket: $!";
$! = 1;
my $s = IO::Select->new();
$s->add($sock);
$sock->autoflush(1) ;
ReadMode 4;

# Display suitable HTML headers and send a series of commands

#print "GSM Card Diagnosticsn";
sendcommand($s, $sock,"at+cerrn ",'Last Error Message','');
sendcommand($s, $sock,"at+cscs= "GSM"n",'Se lect ASCII output','');

print "GSM Card Detailsn";
sendcommand($s, $sock,"at+cgmin ",'Manufact urer Indentification ','');
sendcommand($s, $sock,"at+cgmmn ",'Model Identification' ,'');
sendcommand($s, $sock,"at+cgmrn ",'Revision','' );
sendcommand($s, $sock,"at+cgsnn ",'Serial Number','');

print "Subscriber Identificationn ";
sendcommand($s, $sock,"at+cimin ",'Internationa l Mobile Subscriber Identity','');
sendcommand($s, $sock,"at+ccidn ",'SIM card ID','');
sendcommand($s, $sock,"at+gcapn ",'List of capabilities',' ');
sendcommand($s, $sock,"at+cnumn ",'Subscrib er number','');

printf "Current Statusn";
sendcommand($s, $sock,"at+cpasn ",'Status','(0= ready, 1=unavailable, 2=unknowm, 3=ringing, 4=call-in-progress, 5=asleep');
sendcommand($s, $sock,"at+cfun? n",'Functions', '(power,stk)');
sendcommand($s, $sock,"at+cmer? n",'Term event reporting','(mo de,kpd,disp,ind ,bfr)');
sendcommand($s, $sock,"at+cclk? n",'clock',' (yy/mm/dd hh:mm:ss)');
sendcommand($s, $sock,"at+csqn" , 'Signal Strength','(rss i,ber)');
sendcommand($s, $sock,"at+creg? n",'Network registration ','(n,stat,loca tion,cellident) stat=1(home) ');

printf "SMSn";
sendcommand($s, $sock,"at+cnmi? n",'New Message Indication');
sendcommand($s, $sock,"at+csca? n",'Service centre address');
sendcommand($s, $sock,"at+cmgln ",'List messages');

sendcommand($s, $sock,"at+cscs= "HEX"n",'He x output','');

# Close the socket connection and were done
$sock->close();
ReadMode 0;
exit;


# -----------------------------------------------------------------
# Subroutine to send a command to the diagnostic socket and print the response
sub sendcommand {
my $s = shift;
my $sock = shift;
my $cmd = shift;
my $desc = shift;
my $comment = shift;
my $rtn = '';
#print description
print "$desc ";
#send the command
$sock->syswrite($cmd) ;
sleep 1;
# read the response and print
while ($s->can_read(0))
{
$sock->sysread($rtn,1 );
print $rtn;
}
print "n $commentn";
return;
}
May 5 '10 #1
0 1157

Sign in to post your reply or Sign up for a free account.

Similar topics

1
12518
by: Ronald Evers | last post by:
Hey all, I want to store passwords in a postgresql database. Currently I use the MD5Password class below and I've been developing on windows. I ran into problems when running my application on linux. Linux and Windows, with same JDK's (1.5.0), create different encrypted password strings. So when testing a password created on one platform on the other, it will fail :(
2
2514
by: Tim Williams | last post by:
I'm using Python 2.3.2 and tkFileDialog in a program I have. I'm trying to use this on Linux (RH 8.0) and Windows 2000. When I first upgraded from v2.2 to v2.3. I noticed that tkFileDialog.askopenfilename() returns a tuple on Cancel instead of ''. I found that the Windows version still returns a string (''). Now I'm finding out that tkFileDialog.Directory().show() does this too. >>> d1=tkFileDialog.Directory().show() >>>...
1
3860
by: corrado | last post by:
Hello I have an application running several thread to display some financial data; basically I have a thread displaying HTML tables by means of Tkhtml, another implementing a scrolling ticker based on a Text widget with embedded windows and a thread running the Tkinter mainloop plus several other thread dealing with the scheduling of the contents and the acquisition of data but not using graphic widgets. I run the same code on Linux...
0
1176
by: Iker Arizmendi | last post by:
Hello all. I'm trying to get a server process to do the following on both Linux and Windows: 1) Create a socket and bind it to some port number. 2) Use spawnl to create other processes that will then listen and accept on that socket. On Linux I've managed to do that by using command line
1
1595
by: ÖÜÕÑÌÎ | last post by:
hi,I want to get the names of the files in a directory on the linux and windows platform. I found that _findfirst(),_findnext() can work under windows but the code cann't work under linux ,if some one have advice helpful ,thanks. is there some class useful that can work under windows and linux without much modification
1
3312
by: John | last post by:
I'm trying to write a program that's run on both Windows 98 and Linux. I need a timer, that I can start and when it hits a limit, it needs to call a callback function. I also need to be able to abort the timer before it hits the limit - it's the classic timeout type thing. I'll readily admit I'm no expert on C++, but after a trawl of the WWW pages, there appears to be two solutions depending on whether it's Linux or Windows.
2
10347
by: Andrej Litowka | last post by:
Hi All! If anybody know, how I cann set an enviroment variable (with ANSI C) on Windows similar like on Linux. I tried setenv, but the function doesn't work correct on Windows - it sets env. variables only for calling process or session (in my case, the program will called in cmd.exe), but I need its global. There is no putenv on Windows, only _putenv and there is no _putenv on Linux (or I'm wrong?). I cann use of course something like...
6
1795
by: jake | last post by:
How do you get or save a file from/to a client (button on web page) once they are authenticated? The client could be Mac, Linux or Windows. Can I do it all with IIS and ASP.NET?
3
2535
by: Blubaugh, David A. | last post by:
To All, I was wondering if it was possible to utilize python to share a memory resource between a linux and windows system?? It should be stated that both the Linux (CENTOS 5) and windows are physically located on the same computer. Is any of this possible?
0
1515
by: Blubaugh, David A. | last post by:
Diez, What you have said is extremely concerning. I am now using VMware. With Linux as the Master and windows as the guest operating system. I was wondering if you have ever had to develop a share memory resource between Linux and windows within a Vmware setup?
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10315
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10083
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9946
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.