Click here to Skip to main content
14,979,508 members
Please Sign up or sign in to vote.
2.33/5 (3 votes)
See more:
hi everyone
how i can send byte[] to pc and i know ip of this pc
there is now way
any code
thanks for any help
Posted
Comments
Albin Abel 20-Feb-11 2:40am
   
There are ways. You can use Remoting async call. Actually there are many ways. Do you want code?! or try yourself and comeback if any problems. I have an example of remote call. But this is a sync call you can use BeginInvoke and endInvoke instead of invoke for the async call.

http://www.codeproject.com/Answers/156939/How-to-Copy-Items-from-one-ListView-to-Another-in-.aspx#answer3
Mostafa Elsadany 20-Feb-11 2:45am
   
thanks for help
but if you have sample code
will be amazing
thanks for help
im waiting

Probably the target PC should know what to do with received bytes, hence there is an application, on the target PC, waiting for the bytes. You might make your program an the application running on the target PC communicating via TCP/IP.
:)
   
Comments
Sergey Alexandrovich Kryukov 20-Feb-11 17:50pm
   
Good note to start with, a 5.
I listed options on different level, would you take a look?
--SA
The easiest way is to use Sockets: since the Socket.Send[^] method is designed to send a byte array, it seems the best to use.

There is an example on MSDN[^] of how to use.
   
Comments
Sergey Alexandrovich Kryukov 20-Feb-11 15:36pm
   
I think the level of TcpListener/TcpClient is closer. I listed several levels to approach the problem, please see my Answer.
Anyway, my 5 for your Answer.
--SA
There is no "send bytes" per se, you need to make service part, ideally, a Windows Service.

Let me list your options, low-level to high level:

Sockets. Use the class System.Net.Sockets.Socket.

TCP. Use the classes System.Net.Sockets.TcpListener in server side, System.Net.Sockets.TcpClient of client side. I would say, this is better option.

Remoting or WCF. See overview and technology samples in MSDN.

Best way to find a sample is a search in CodeProject articles, next one is Google. I used to see a number of really nice simple samples. For the classes listed above, there are nice Microsoft samples in the help or MSDN pages on those classes. This is the reason why using these classes is the easiest from the standpoint of search effort — almost no search. Remoting or WCF will require a lot more search, but the code can be very compact. Using these technologies without understanding can give very inadequate results.

I really think you don't have a good justification to make other people to do the search for you; CodeProject help is normally based on the effort done by the Inquirer.

—SA
   
v4
Comments
Nish Nishant 20-Feb-11 17:30pm
   
Voted 5.
Sergey Alexandrovich Kryukov 20-Feb-11 17:47pm
   
Thank you, Nishant.
As to the final resolution of OP problem, it looks like long way.
--SA
CPallini 21-Feb-11 6:01am
   
Good one, 5.
Sergey Alexandrovich Kryukov 21-Feb-11 15:47pm
   
Thank you.
--SA
Espen Harlinn 21-Feb-11 9:32am
   
My 5 - good effort :)
Sergey Alexandrovich Kryukov 21-Feb-11 16:15pm
   
Thank you.
Did you sleep well? :-)
--SA
Espen Harlinn 22-Feb-11 12:14pm
   
Oh yes, no trouble in that department :)
Hi ther,

I wrote a class library and article a little while ago to do just the same thing. While I used it for a network game, it can actaully be used for any program. Have a look at:
Fast Networking Library 2

It uses Sockets to communicate with protocol Tcp. If you don't understand all of it you could also have a look at my riginal article:
Network gaming classes and functions


Hope this helps,

Ed :)
   
Comments
Sergey Alexandrovich Kryukov 20-Feb-11 15:40pm
   
Ed, this is maybe interesting works, but may be not the best source of sample code, especially for the beginner. There are many better samples, very simple and free from unwanted detail; please see my answer.
(By the way, I did not vote.)
--SA
Ed Nutting 20-Feb-11 17:07pm
   
Hi, yes okay I had not thought of that... Ur answer is very good and don't worry, your reasons would have been fair if you had.

Ed :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900