The port and protocol used by Samba services (a combination of a set of TCP UDP protocols, mainly using the CIFS protocol, with a Java example)

Source: Internet
Author: User

The ports and protocols used by the Samba service:

1) Port 137 (UDP)-NetBIOS name service; NMBD
2) port 138 (UDP)-NetBIOS Datagram Service 3) port 139 (TCP)-File and print sharing, SMBD (SMB (Server Message Block) protocol, mainly used on LAN, file sharing protocol) 4) port 3 (TCP)-for LDAP (Active Directory Mode) 5) port 445 (TCP)-NetBIOS service uses this port in WinDOS 2000 and later versions (Common Internet File System , CIFS, which is the SMB protocol that is extended to the Internet after you implement Internet File sharing)
6) Port 901 (TCP)-for SWAT, for Web management Samba
File sharing protocol between Windows systems: NetBEUI (NetBIOS Extend User Interface) protocol and Ipx/spx Protocol
The NetBEUI protocol is a compact, communication-efficient broadcast protocol that does not need to be set up after installation and is especially suitable for transmitting data in a "Network Neighborhood".
NetBEUI lack of Routing and Network layer addressing function is not only its greatest advantage, but also its biggest disadvantage. Because it does not require additional network addresses and network layer Kinsoku, it is fast and effective and works well for small workgroup environments that are bridged only by a single network or an entire environment.
Because routing is not supported, NetBEUI will never become the primary protocol for the corporate network. The only address in the NetBEUI frame is the data Link Layer media access control (MAC) address, which identifies the NIC but does not identify the network. The router forwards the frame to the final destination by the network address, and the NetBEUI frame lacks that information completely.
Ipx/spx (Internetwork Packet exchange/sequences Packet exchange,internet packet switching/sequential packet switching ipx/spx) is a set of communications protocols for Novell Corporation. The distinctive difference with NetBEUI is that ipx/spx is relatively large and has strong adaptability in complex environment. This is because ipx/spx in the beginning of the design to consider the problem of the network segment, so it has a powerful routing function, suitable for large-scale network use.
IPX mainly realizes the maintenance and termination of the connection between network devices. The SPX protocol is the auxiliary protocol of IPX, which mainly realizes the grouping of information, tracking packet transmission and guaranteeing the intact transmission of information. The IPX protocol is responsible for the transmission of the packet, and the SPX is responsible for the integrity of the packet transmission.
File sharing between Linux systems and Liunx files sharing with Windows systems: IBM SMB, Server Information block protocol
The server Information block (SMB) protocol is an IBM protocol that is used to share files, printers, serial ports, and so on between computers. The SMB protocol can be used on the TCP/IP protocol of the Internet or on other network protocols such as IPX and NetBEUI.


http://blog.csdn.net/wangsifu2009/article/details/6780749

------------------------------------------------------------------------------
shared file upload and download based on SMB/JCIFS protocol (shared files in local area network to get files) SMBOriginally developed by the IBM Berry Feigenbaum (Barry Feigenbaum), the aim was to transform the local file interface "Interrupt 13" in the DOS operating system into a network file system. Microsoft later made a major change to this development, and this changed version is also the most common version. Microsoft has combined the SMB protocol with the network Management program it developed with 3Com and continues to add new features to Windows for Workgroups and later versions of Windows. CIFS (Common Internet File System)Universal Internet File System

Network file sharing between Windows hosts is achieved by using Microsoft's own CIFS service.

CIFS is a newly proposed protocol that enables programs to access files on a remote internet computer and require services for this computer. CIFS uses client/server mode. The client program requests a server program on the server to service it. The server obtains the request and returns a response. CIFS is a public or open SMB protocol version and is used by Microsoft. The SMB protocol (see the last noun explanation) is now a protocol for server file access and printing on a local area network. Like the SMB protocol, CIFS runs at the top, rather than at the bottom, as the TCP/IP protocol does. CIFS can be seen as an implementation of application protocols such as file transfer protocols and hypertext transfer protocols.

CIFS enables you to achieve the following features:

1. Access the server local files and read and write these files

2. Share some file blocks with other users

3. Automatically restore the connection to the network when disconnected

4. Using Western European character filenames

In general, CIFS users get better control of files than FTP. It provides a potentially more direct interface to the server program, which is better than a browser using the HTTP protocol. The most typical application for CIFS is that Windows users can find other hosts on the network and access their shared folders from their web places.

CIFS is an open standard and has been submitted to the IETF as an Internet application standard.

jcifs is an implementation of CIFS in Java and is an open source project for the maintenance development of the Samba organization, focusing on the design and implementation of the CIFS protocol using the Java language. They designed jcifs as a complete, rich, scalable and thread-safe client library. This library can be applied to a variety of Java virtual machines to access network resources that follow the CIFS/SMB Network Transport protocol. Similar to the Java.io.File interface form, proved to be effective and easy to use in multi-threaded working mode

Java code
  1. Package COM.SMB;
  2. Import Java.io.BufferedInputStream;
  3. Import Java.io.BufferedOutputStream;
  4. Import Java.io.File;
  5. Import Java.io.FileInputStream;
  6. Import Java.io.FileOutputStream;
  7. Import java.io.IOException;
  8. Import Java.io.InputStream;
  9. Import Java.io.OutputStream;
  10. Import Jcifs.smb.SmbFile;
  11. Import Jcifs.smb.SmbFileInputStream;
  12. Import Jcifs.smb.SmbFileOutputStream;
  13. public class Smbtest {
  14. /**
  15. * Get files from shared files on LAN and save on Local disk
  16. * @param remoteurl shared computer path such as: Smb//administrator:[email Protected]/smb/1221.zip, SMB is a shared file
  17. * Note: If the connection is not on, there is an error message, and the wrong information is the user name Live password error Modify the shared machine folder options to see the removal of the shared simple folder check.
  18. * @param localdir Local path such as: d:/
  19. */
  20. public static void Smbget (String remoteurl,string localdir) {
  21. InputStream in = null;
  22. OutputStream out = null;
  23. try {
  24. Smbfile smbfile = new Smbfile (Remoteurl);
  25. String fileName = Smbfile.getname ();
  26. File LocalFile = new file (localdir+file.separator+filename);
  27. in = new Bufferedinputstream (new Smbfileinputstream (Smbfile));
  28. out = new Bufferedoutputstream (new FileOutputStream (LocalFile));
  29. byte []buffer = new byte[1024];
  30. while ((In.read (buffer))! =-1) {
  31. Out.write (buffer);
  32. Buffer = new byte[1024];
  33. }
  34. } catch (Exception e) {
  35. E.printstacktrace ();
  36. }finally{
  37. try {
  38. Out.close ();
  39. In.close ();
  40. } catch (IOException e) {
  41. E.printstacktrace ();
  42. }
  43. }
  44. }
  45. /**
  46. * Upload files from local disk to LAN shared file
  47. * @param remoteurl shared computer path such as: Smb//administrator:[email PROTECTED]/SMB
  48. * @param localfilepath Local path such as: d:/
  49. */
  50. public static void Smbput (String remoteurl,string localfilepath) {
  51. InputStream in = null;
  52. OutputStream out = null;
  53. try {
  54. File LocalFile = new file (Localfilepath);
  55. String fileName = Localfile.getname ();
  56. Smbfile remotefile = new Smbfile (remoteurl+ "/" +filename);
  57. in = new Bufferedinputstream (new FileInputStream (LocalFile));
  58. out = new Bufferedoutputstream (new Smbfileoutputstream (RemoteFile));
  59. byte []buffer = new byte[1024];
  60. while ((In.read (buffer))! =-1) {
  61. Out.write (buffer);
  62. Buffer = new byte[1024];
  63. }
  64. } catch (Exception e) {
  65. E.printstacktrace ();
  66. }finally{
  67. try {
  68. Out.close ();
  69. In.close ();
  70. } catch (IOException e) {
  71. E.printstacktrace ();
  72. }
  73. }
  74. }
  75. public static void Main (string[] args) {
  76. Smbput ("Smb://administrator:[email protected]/smb", "E:/1221.zip");
  77. Smbget ("Smb://administrator:[email protected]/smb/1221.zip", "d:/");
  78. }
  79. }
http://iteye.blog.163.com/blog/static/1863080962012111155514179/
------------------------------------------------------------------------------





The port and protocol used by Samba services (a combination of a set of TCP UDP protocols, mainly using the CIFS protocol, with a Java example)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.