473,396 Members | 2,016 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to convert socket in linux to work on windows

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::UNIX;
use Term::ReadKey;
use IO::Select;
use CGI qw(:standard);
use CGI::Carp qw(fatalsToBrowser);

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

# Open the socket connection to GSMD
my $sock = new IO::Socket::UNIX (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",'Select ASCII output','');

print "GSM Card Detailsn";
sendcommand($s,$sock,"at+cgmin",'Manufacturer 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",'International Mobile Subscriber Identity','');
sendcommand($s,$sock,"at+ccidn",'SIM card ID','');
sendcommand($s,$sock,"at+gcapn",'List of capabilities','');
sendcommand($s,$sock,"at+cnumn",'Subscriber 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','(pow er,stk)');
sendcommand($s,$sock,"at+cmer?n",'Term event reporting','(mode,kpd,disp,ind,bfr)');
sendcommand($s,$sock,"at+cclk?n",'clock','(yy/mm/dd hh:mm:ss)');
sendcommand($s,$sock,"at+csqn", 'Signal Strength','(rssi,ber)');
sendcommand($s,$sock,"at+creg?n",'Network registration ','(n,stat,location,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",'Hex 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 1146

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

Similar topics

1
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...
2
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...
1
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...
0
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...
1
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...
1
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...
2
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....
6
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
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...
0
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.