## 1 Introduction
Ontologies can play a crucial role in this regard by providing a common semantic framework for modeling social interactions [25; 26; 27; 28; 29] among IoT devices. Standardization efforts, such as the development of common APIs and protocols, can also facilitate interoperability among IoT devices from different vendors and platforms [30]. Furthermore, the emergence of novel social relationships that surpass traditional human-to-human interactions presents a significant challenge [13]. In the SIoT landscape, interactions involving humans, devices, and hybrid social entities have grown increasingly complex. To fully unlock the potential of the SIoT paradigm, there is a pressing need to develop robust mechanisms that can effectively manage and harmonize these interactions [31]. Failing to address this challenge not only hampers the seamless integration of these entities, but also restricts the realization of the SIoT paradigm's complete potential. Additionally, efficient service discovery mechanisms are essential to enable seamless integration and resource allocation in heterogeneous SIoT environments [32]. The ability to discover and access services across different entities and applications within the SIoT system is crucial for its smooth operation and to maximize potential benefits. Developing a generic solution adaptable to multiple domains is an imperative challenge to overcome [8; 11; 33]. A scalable and interoperable solution that can be readily applied to diverse domains within the SIoT ecosystem promotes efficiency, interoperability, and reusability. Finally, rigorous evaluations using representative use case scenarios [13; 34] are indispensable to validate the effectiveness and practicality of SIoT solutions. Our proposed middleware, the Semantic Social Network of Things Middleware (S2 NeTM), is specifically designed to tackle critical issues in the SIoT domain. With its innovative features and functionalities, S2 NeTM offers comprehensive solutions to overcome obstacles in areas such as semantic interoperability, where S2 NeTM leverages advanced ontology and reasoning mechanisms to establish a standardized communication framework and data format. This ensures seamless data exchange and meaningful interaction among diverse IoT devices within social contexts. Additionally, S2 NeTM incorporates dynamic relationship selection, trustworthiness management, and efficient service discovery, effectively addressing the evolving needs of SIoT environments. Furthermore, through evaluation using a real use case scenario, our middleware demonstrates its effectiveness, practicality, and real-world applicability. The main contributions of this paper are as follows:  
1. **The specification of the S2 NeTM**, integrating a variety of components, including _Context Management_, driving data analysis and context-aware services; _Owner Control_, ensuring access security, privacy, and device ownership; _User Profiling_, fostering personalization; _Service Discovery_, promoting seamless connectivity; _Trustworthiness Management_, ensuring system reliability; _Friendship Selection_ and _Relationship Management_, enabling efficient interactions through social connections; and _Semantic Engines_, facilitating semantic data interpretation. Collectively, these components form the foundation of advanced SIoT applications. 2. **The development of an ontology**, providing a standardized vocabulary for describing the relationships between IoT devices, which thereby facilitates the semantic annotation and reasoning of heterogeneous data within the proposed S2 NeTM. 3. **An evaluation with a real-world use case**, the \"Green Route\", demonstrating the effectiveness of the proposed S2 NeTM within a smart city environment. The Green Route provides a personalized, eco-friendly route planning service to users. The evaluation demonstrates that S2 NeTM enhances the quality of social IoT services, provides personalized recommendations, and significantly improves the user experience.