Transferring Image File Using Sockets  
Author Message
Biju S Melayil





PostPosted: .NET Framework Networking and Communication, Transferring Image File Using Sockets Top

Hi all,

I have an Scenario where i have to send an Image (max size of 40KB) from the Windows Mobile 5.0 to an webserver. Currently iam using an Web Service to transfer the file as Byte array.

But the problem iam facing right now is tat the Transfer takes a long time and transaction fails frequently. I heard tat there is an option using Socket where you will be able to send data much faster.

Anyone know how to use Socket to send the image from the Mobile to the server. Pl. give your valuable inputs on this issue.
Thanks in Advance

Regards

Biju S Melayil



.NET Development36  
 
 
RizwanSharp





PostPosted: .NET Framework Networking and Communication, Transferring Image File Using Sockets Top

You have already done half of the work.

See TcpListener class in MSDN for Server side imlementation and see TcpClient classs for client side implementation. These are wrapper on Socket class in .Net for novice network programmers of .Net. Socket has more complexities as compare to these helper classes.

Host a Listener, listening on a specific port on server and connect client to it, once connection is extablished you can send bytes read from the image to the server. You may need to send a very little extra data with original file bytes to let server know, whats name of the image, how many bytes have you sent etc.

In other words you need to send data in some format like xml tags or some other thing, that's up to you.

Best Regards,

Rizwan



 
 
Mike Flasko





PostPosted: .NET Framework Networking and Communication, Transferring Image File Using Sockets Top

Another option to look at is Socket.SendFile

 
 
Biju S Melayil





PostPosted: .NET Framework Networking and Communication, Transferring Image File Using Sockets Top

hi Rizwan,

Thanks for the response.
I have a small doubt which i would like to clear with you...
I have created the Client Side Application and iam not clear on Hosting the Listener.
Should it be an Class file or an Web Page. Becuase wotever Application i have seen for the listener in the MSDN or in other web sites they were Windows Application which were running. I wont be able to upload this listener in our web server because of some restrictions.

Pl. Let me know how to create this Listener for the website

thanks again for your response.

Kind Regards
Biju S Melayil

 
 
RizwanSharp





PostPosted: .NET Framework Networking and Communication, Transferring Image File Using Sockets Top

If you have to use sockets, need performance then it can be done in Windows Application. Hosting a Listner means that run the server application on a computer and listen for incoming connections. For more information see TcpListner class in MSDN and its example!

Best Regards,



 
 
Biju S Melayil





PostPosted: .NET Framework Networking and Communication, Transferring Image File Using Sockets Top

thanks Rizwan.

As you have mentioned "if you have to use Sockets".
Is there any other better way to transmit this images from the mobile to the server.

Pl Let me know

Kind Regards
Biju S Melayil


 
 
RizwanSharp





PostPosted: .NET Framework Networking and Communication, Transferring Image File Using Sockets Top

There are different ways to transmit files but Socket is most efficient way as already discussed. Are you fcing any diffculty in using Socket If so please use TcpClient and TcpListener for your conveinience. And also see this, this guy has done the same job as your are doing from device to PC image transmission.

http://forums.microsoft.com/MSDN/showpost.aspx postid=933987&siteid=1

Best Regards,

Rizwan



 
 
Biju S Melayil





PostPosted: .NET Framework Networking and Communication, Transferring Image File Using Sockets Top

Hi Rizwan,

Thanks for your speedy replies.
The Major Diffuculty iam facing for use of Socket is that i wont be able to run an Service on an Console Application for TcpListener as our server dont allow us to install those kinda applications in that web server. Right now as Ahmed as mentioned in that post iam using web service which has the Image as Byte Array. But it takes a lot of time to upload like 2 or 3 minutes and sometime if u send multiple files its getting Timeout. As iam a toddler to this socket and listener kinda programming pl help me out as the deadline is getting nearer to us ;)

Thank you once again for Patiently replying for my mails

Kind Regards
Biju S Melayil


 
 
RizwanSharp





PostPosted: .NET Framework Networking and Communication, Transferring Image File Using Sockets Top

See there is solution suggested by me in that post and it worked that's why he market the post as answered if you are facing any difficult feel free to contact me again. But i'm not good with Web services but I'l try to help may be I learn something new in helping you out.

BEst Regards,

Rizwan



 
 
Biju S Melayil





PostPosted: .NET Framework Networking and Communication, Transferring Image File Using Sockets Top

hi Rizwan,

Thanks a lot for guiding me on this issue.
Right now am looking at the web service because of server restrictions we have.
I would keep you posted on this

Thanks a lot
Regards

Biju S Melayil


 
 
RizwanSharp





PostPosted: .NET Framework Networking and Communication, Transferring Image File Using Sockets Top

You are more than welcome Biju :).

Best Regards,

Rizwan